





'''simple docstring'''







import inspect
import unittest

from transformers import ResNetConfig
from transformers.testing_utils import require_torch, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

from ...test_backbone_common import BackboneTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
					import torch
					from torch import nn

					from transformers import ResNetBackbone, ResNetForImageClassification, ResNetModel
					from transformers.models.resnet.modeling_resnet import RESNET_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
					from PIL import Image

					from transformers import AutoImageProcessor


class        __a   :

							def __init__(				self				:  Tuple							,  __magic_name__				:  List[str]							,  __magic_name__				:  Union[str, Any]=3							,  __magic_name__				:  str=32							,  __magic_name__				:  int=3							,  __magic_name__				:  List[Any]=10							,  __magic_name__				:  int=[10, 20, 30, 40]							,  __magic_name__				:  str=[1, 1, 2, 1]							,  __magic_name__				:  List[Any]=True							,  __magic_name__				:  Any=True							,  __magic_name__				:  str="relu"							,  __magic_name__				:  Optional[Any]=3							,  __magic_name__				:  List[str]=None							,  __magic_name__				:  Tuple=["stage2", "stage3", "stage4"]							,  __magic_name__				:  List[str]=[2, 3, 4]							,  )       ->							List[Any]:







													"""simple docstring"""
													UpperCAmelCase_      :   Dict      =	parent
													UpperCAmelCase_      :   List[str]      =	batch_size
													UpperCAmelCase_      :   Union[str, Any]      =	image_size
													UpperCAmelCase_      :   int      =	num_channels
													UpperCAmelCase_      :   str      =	embeddings_size
													UpperCAmelCase_      :   List[Any]      =	hidden_sizes
													UpperCAmelCase_      :   Any      =	depths
													UpperCAmelCase_      :   Optional[int]      =	is_training
													UpperCAmelCase_      :   Optional[Any]      =	use_labels
													UpperCAmelCase_      :   Union[str, Any]      =	hidden_act
													UpperCAmelCase_      :   Dict      =	num_labels
													UpperCAmelCase_      :   str      =	scope
													UpperCAmelCase_      :   int      =	len(__magic_name__ )
													UpperCAmelCase_      :   Union[str, Any]      =	out_features
													UpperCAmelCase_      :   List[Any]      =	out_indices

							def      UpperCAmelCase__						(				self				:  Union[str, Any] )       ->							Dict:







													"""simple docstring"""
													UpperCAmelCase_      :   int      =	floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size] )

													UpperCAmelCase_      :   Tuple      =	None
													if self.use_labels:
																			UpperCAmelCase_      :   str      =	ids_tensor([self.batch_size]							,  self.num_labels )

													UpperCAmelCase_      :   List[str]      =	self.get_config()

													return config, pixel_values, labels

							def      UpperCAmelCase__						(				self				:  Dict )       ->							Dict:







													"""simple docstring"""
													return ResNetConfig(
													    num_channels=self.num_channels							,  embeddings_size=self.embeddings_size							,  hidden_sizes=self.hidden_sizes							,  depths=self.depths							,  hidden_act=self.hidden_act							,  num_labels=self.num_labels							,  out_features=self.out_features							,  out_indices=self.out_indices							,  )

							def      UpperCAmelCase__						(				self				:  Optional[int]							,  __magic_name__				:  List[Any]							,  __magic_name__				:  Any							,  __magic_name__				:  Dict )       ->							Union[str, Any]:







													"""simple docstring"""
													UpperCAmelCase_      :   Tuple      =	ResNetModel(config=__magic_name__ )
													model.to(__magic_name__ )
													model.eval()
													UpperCAmelCase_      :   List[Any]      =	model(__magic_name__ )
													# expected last hidden states: B, C, H // 32, W // 32
													self.parent.assertEqual(
													    result.last_hidden_state.shape							,  (self.batch_size, self.hidden_sizes[-1], self.image_size // 32, self.image_size // 32)							,  )

							def      UpperCAmelCase__						(				self				:  Optional[int]							,  __magic_name__				:  Tuple							,  __magic_name__				:  Optional[int]							,  __magic_name__				:  int )       ->							Optional[int]:







													"""simple docstring"""
													UpperCAmelCase_      :   Any      =	self.num_labels
													UpperCAmelCase_      :   List[str]      =	ResNetForImageClassification(__magic_name__ )
													model.to(__magic_name__ )
													model.eval()
													UpperCAmelCase_      :   str      =	model(__magic_name__							,  labels=__magic_name__ )
													self.parent.assertEqual(result.logits.shape							,  (self.batch_size, self.num_labels) )

							def      UpperCAmelCase__						(				self				:  Any							,  __magic_name__				:  Union[str, Any]							,  __magic_name__				:  Optional[int]							,  __magic_name__				:  int )       ->							List[str]:







													"""simple docstring"""
													UpperCAmelCase_      :   str      =	ResNetBackbone(config=__magic_name__ )
													model.to(__magic_name__ )
													model.eval()
													UpperCAmelCase_      :   Optional[int]      =	model(__magic_name__ )

													# verify feature maps
													self.parent.assertEqual(len(result.feature_maps )							,  len(config.out_features ) )
													self.parent.assertListEqual(list(result.feature_maps[0].shape )							,  [self.batch_size, self.hidden_sizes[1], 4, 4] )

													# verify channels
													self.parent.assertEqual(len(model.channels )							,  len(config.out_features ) )
													self.parent.assertListEqual(model.channels							,  config.hidden_sizes[1:] )

													# verify backbone works with out_features=None
													UpperCAmelCase_      :   int      =	None
													UpperCAmelCase_      :   List[str]      =	ResNetBackbone(config=__magic_name__ )
													model.to(__magic_name__ )
													model.eval()
													UpperCAmelCase_      :   List[Any]      =	model(__magic_name__ )

													# verify feature maps
													self.parent.assertEqual(len(result.feature_maps )							,  1 )
													self.parent.assertListEqual(list(result.feature_maps[0].shape )							,  [self.batch_size, self.hidden_sizes[-1], 1, 1] )

													# verify channels
													self.parent.assertEqual(len(model.channels )							,  1 )
													self.parent.assertListEqual(model.channels							,  [config.hidden_sizes[-1]] )



							def      UpperCAmelCase__						(				self				:  Any )       ->							List[str]:







													"""simple docstring"""
													UpperCAmelCase_      :   Any      =	self.prepare_config_and_inputs()
													UpperCAmelCase_    ,							UpperCAmelCase_    ,							UpperCAmelCase_      :   List[Any]      =	config_and_inputs
													UpperCAmelCase_      :   Union[str, Any]      =	{'''pixel_values''': pixel_values}
													return config, inputs_dict





@require_torch
class        __a   (lowerCamelCase							,		lowerCamelCase							,		unittest.TestCase  ):
							__a       : List[Any]          =							(
							    (
							        ResNetModel,
							        ResNetForImageClassification,
							        ResNetBackbone,
							    )
							    if is_torch_available()
							    else ()
							)
							__a       : Optional[Any]          =							(
							    {"feature-extraction": ResNetModel, "image-classification": ResNetForImageClassification}
							    if is_torch_available()
							    else {}
							)

							__a       : List[str]          =							True
							__a       : Optional[int]          =							False
							__a       : Tuple          =							False
							__a       : Optional[int]          =							False
							__a       : Optional[int]          =							False

							def      UpperCAmelCase__						(				self				:  Dict )       ->							List[str]:







													"""simple docstring"""
													UpperCAmelCase_      :   Tuple      =	ResNetModelTester(self )
													UpperCAmelCase_      :   Any      =	ConfigTester(self							,  config_class=__magic_name__							,  has_text_modality=__magic_name__ )

							def      UpperCAmelCase__						(				self				:  int )       ->							List[Any]:







													"""simple docstring"""
													self.create_and_test_config_common_properties()
													self.config_tester.create_and_test_config_to_json_string()
													self.config_tester.create_and_test_config_to_json_file()
													self.config_tester.create_and_test_config_from_and_save_pretrained()
													self.config_tester.create_and_test_config_with_num_labels()
													self.config_tester.check_config_can_be_init_without_params()
													self.config_tester.check_config_arguments_init()

							def      UpperCAmelCase__						(				self				:  Optional[int] )       ->							str:







													"""simple docstring"""
													return

							@unittest.skip(reason='''ResNet does not use inputs_embeds''' )
							def      UpperCAmelCase__						(				self				:  Dict )       ->							int:







													"""simple docstring"""
													pass

							@unittest.skip(reason='''ResNet does not support input and output embeddings''' )
							def      UpperCAmelCase__						(				self				:  List[str] )       ->							Any:







													"""simple docstring"""
													pass

							def      UpperCAmelCase__						(				self				:  int )       ->							List[Any]:







													"""simple docstring"""
													UpperCAmelCase_    ,							UpperCAmelCase_      :   Any      =	self.model_tester.prepare_config_and_inputs_for_common()

													for model_class in self.all_model_classes:
																			UpperCAmelCase_      :   Optional[Any]      =	model_class(__magic_name__ )
																			UpperCAmelCase_      :   Any      =	inspect.signature(model.forward )
																			# signature.parameters is an OrderedDict => so arg_names order is deterministic
																			UpperCAmelCase_      :   Optional[Any]      =	[*signature.parameters.keys()]

																			UpperCAmelCase_      :   int      =	['''pixel_values''']
																			self.assertListEqual(arg_names[:1]							,  __magic_name__ )

							def      UpperCAmelCase__						(				self				:  str )       ->							Any:







													"""simple docstring"""
													UpperCAmelCase_      :   Tuple      =	self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_model(*__magic_name__ )

							def      UpperCAmelCase__						(				self				:  str )       ->							Optional[int]:







													"""simple docstring"""
													UpperCAmelCase_      :   Union[str, Any]      =	self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_backbone(*__magic_name__ )

							def      UpperCAmelCase__						(				self				:  str )       ->							Optional[int]:







													"""simple docstring"""
													UpperCAmelCase_    ,							UpperCAmelCase_      :   Dict      =	self.model_tester.prepare_config_and_inputs_for_common()

													for model_class in self.all_model_classes:
																			UpperCAmelCase_      :   List[Any]      =	model_class(config=__magic_name__ )
																			for name, module in model.named_modules():
																									if isinstance(__magic_name__							,  (nn.BatchNormad, nn.GroupNorm) ):
																															self.assertTrue(
																															    torch.all(module.weight == 1 )							,  msg=F"""Parameter {name} of model {model_class} seems not properly initialized"""							,  )
																															self.assertTrue(
																															    torch.all(module.bias == 0 )							,  msg=F"""Parameter {name} of model {model_class} seems not properly initialized"""							,  )

							def      UpperCAmelCase__						(				self				:  List[str] )       ->							Optional[Any]:







													"""simple docstring"""
													def check_hidden_states_output(__magic_name__				:  Optional[int]							,  __magic_name__				:  Tuple							,  __magic_name__				:  List[str] ):
																			UpperCAmelCase_      :   Optional[Any]      =	model_class(__magic_name__ )
																			model.to(__magic_name__ )
																			model.eval()

																			with torch.no_grad():
																									UpperCAmelCase_      :   str      =	model(**self._prepare_for_class(__magic_name__							,  __magic_name__ ) )

																			UpperCAmelCase_      :   List[str]      =	outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states

																			UpperCAmelCase_      :   List[str]      =	self.model_tester.num_stages
																			self.assertEqual(len(__magic_name__ )							,  expected_num_stages + 1 )

																			# ResNet's feature maps are of shape (batch_size, num_channels, height, width)
																			self.assertListEqual(
																			    list(hidden_states[0].shape[-2:] )							,  [self.model_tester.image_size // 4, self.model_tester.image_size // 4]							,  )

													UpperCAmelCase_    ,							UpperCAmelCase_      :   Union[str, Any]      =	self.model_tester.prepare_config_and_inputs_for_common()
													UpperCAmelCase_      :   Any      =	['''basic''', '''bottleneck''']
													for model_class in self.all_model_classes:
																			for layer_type in layers_type:
																									UpperCAmelCase_      :   List[Any]      =	layer_type
																									UpperCAmelCase_      :   Optional[Any]      =	True
																									check_hidden_states_output(__magic_name__							,  __magic_name__							,  __magic_name__ )

																									# check that output_hidden_states also work using config
																									del inputs_dict["output_hidden_states"]
																									UpperCAmelCase_      :   int      =	True

																									check_hidden_states_output(__magic_name__							,  __magic_name__							,  __magic_name__ )

							@unittest.skip(reason='''ResNet does not use feedforward chunking''' )
							def      UpperCAmelCase__						(				self				:  Optional[int] )       ->							Optional[Any]:







													"""simple docstring"""
													pass

							def      UpperCAmelCase__						(				self				:  Optional[int] )       ->							List[Any]:







													"""simple docstring"""
													UpperCAmelCase_      :   int      =	self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_for_image_classification(*__magic_name__ )



							@slow
							def      UpperCAmelCase__						(				self				:  str )       ->							Optional[int]:







													"""simple docstring"""
													for model_name in RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																			UpperCAmelCase_      :   List[str]      =	ResNetModel.from_pretrained(__magic_name__ )
																			self.assertIsNotNone(__magic_name__ )





def 							lowerCamelCase_   (	)			->						List[str]:
						UpperCAmelCase_      :   int      =	Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png''' )
						return image


@require_torch
@require_vision
class        __a   (unittest.TestCase  ):

							@cached_property
							def      UpperCAmelCase__						(				self				:  Optional[int] )       ->							Optional[int]:







													"""simple docstring"""
													return (
													    AutoImageProcessor.from_pretrained(RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[0] )
													    if is_vision_available()
													    else None
													)



							@slow
							def      UpperCAmelCase__						(				self				:  int )       ->							int:







													"""simple docstring"""
													UpperCAmelCase_      :   int      =	ResNetForImageClassification.from_pretrained(RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[0] ).to(__magic_name__ )

													UpperCAmelCase_      :   Union[str, Any]      =	self.default_image_processor
													UpperCAmelCase_      :   Optional[Any]      =	prepare_img()
													UpperCAmelCase_      :   Optional[int]      =	image_processor(images=__magic_name__							,  return_tensors='''pt''' ).to(__magic_name__ )

													# forward pass
													with torch.no_grad():
																			UpperCAmelCase_      :   Optional[Any]      =	model(**__magic_name__ )

													# verify the logits
													UpperCAmelCase_      :   str      =	torch.Size((1, 10_00) )
													self.assertEqual(outputs.logits.shape							,  __magic_name__ )

													UpperCAmelCase_      :   Tuple      =	torch.tensor([-1_1.1_0_6_9, -9.7_8_7_7, -8.3_7_7_7] ).to(__magic_name__ )

													self.assertTrue(torch.allclose(outputs.logits[0, :3]							,  __magic_name__							,  atol=1E-4 ) )





@require_torch
class        __a   (lowerCamelCase							,		unittest.TestCase  ):
							__a       : Optional[Any]          =							(ResNetBackbone,) if is_torch_available() else ()
							__a       : List[str]          =							False
							__a       : Tuple          =							ResNetConfig

							def      UpperCAmelCase__						(				self				:  Optional[Any] )       ->							List[str]:







													"""simple docstring"""
													UpperCAmelCase_      :   Any      =	ResNetModelTester(self )













import unittest

import numpy as np
from datasets import load_dataset

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
					import torch

if is_vision_available():
					from PIL import Image

					from transformers import SegformerImageProcessor





class        a__      (	unittest.TestCase		):






		def __init__(      self							, lowercase__							, lowercase__=7							, lowercase__=3							, lowercase__=30							, lowercase__=400							, lowercase__=True							, lowercase__=None							, lowercase__=True							, lowercase__=[0.5, 0.5, 0.5]							, lowercase__=[0.5, 0.5, 0.5]							, lowercase__=False							, )				->				Tuple:
				__A    =							size if size is not None else {"height": 30, "width": 30}
				__A    =							parent
				__A    =							batch_size
				__A    =							num_channels
				__A    =							min_resolution
				__A    =							max_resolution
				__A    =							do_resize
				__A    =							size
				__A    =							do_normalize
				__A    =							image_mean
				__A    =							image_std
				__A    =							do_reduce_labels






		def 					_lowerCamelCase					(      self						)				->				Union[str, Any]:
				return {
				    "do_resize": self.do_resize,
				    "size": self.size,
				    "do_normalize": self.do_normalize,
				    "image_mean": self.image_mean,
				    "image_std": self.image_std,
				    "do_reduce_labels": self.do_reduce_labels,
				}



def      UpperCAmelCase						( ):


		'''simple docstring'''

		__A    =							load_dataset("hf-internal-testing/fixtures_ade20k"					,     split="test"	)

		__A    =							Image.open(dataset[0]["file"]	)
		__A    =							Image.open(dataset[1]["file"]	)

		return image, map



def      UpperCAmelCase						( ):


		'''simple docstring'''

		__A    =							load_dataset("hf-internal-testing/fixtures_ade20k"					,     split="test"	)

		__A    =							Image.open(dataset[0]["file"]	)
		__A    =							Image.open(dataset[1]["file"]	)
		__A    =							Image.open(dataset[2]["file"]	)
		__A    =							Image.open(dataset[3]["file"]	)

		return [imagea, imagea], [mapa, mapa]





@require_torch
@require_vision
class        a__      (	lowerCAmelCase__	,       unittest.TestCase		):
		UpperCAmelCase_							:       Dict 					= SegformerImageProcessor if is_vision_available() else None






		def 					_lowerCamelCase					(      self						)				->				List[str]:
				__A    =							SegformerImageProcessingTester(self						)






		@property
		def 					_lowerCamelCase					(      self						)				->				str:
				return self.image_processor_tester.prepare_image_processor_dict()






		def 					_lowerCamelCase					(      self						)				->				Union[str, Any]:
				__A    =							self.image_processing_class(**self.image_processor_dict						)
				self.assertTrue(hasattr(lowercase__							, "do_resize"						)						)
				self.assertTrue(hasattr(lowercase__							, "size"						)						)
				self.assertTrue(hasattr(lowercase__							, "do_normalize"						)						)
				self.assertTrue(hasattr(lowercase__							, "image_mean"						)						)
				self.assertTrue(hasattr(lowercase__							, "image_std"						)						)
				self.assertTrue(hasattr(lowercase__							, "do_reduce_labels"						)						)






		def 					_lowerCamelCase					(      self						)				->				Union[str, Any]:
				__A    =							self.image_processing_class.from_dict(self.image_processor_dict						)
				self.assertEqual(image_processor.size							, {"height": 30, "width": 30}						)
				self.assertEqual(image_processor.do_reduce_labels							, lowercase__						)

				__A    =							self.image_processing_class.from_dict(self.image_processor_dict							, size=42							, reduce_labels=lowercase__						)
				self.assertEqual(image_processor.size							, {"height": 42, "width": 42}						)
				self.assertEqual(image_processor.do_reduce_labels							, lowercase__						)






		def 					_lowerCamelCase					(      self						)				->				Optional[int]:
				pass






		def 					_lowerCamelCase					(      self						)				->				Union[str, Any]:
				# Initialize image_processing
				__A    =							self.image_processing_class(**self.image_processor_dict						)
				# create random PIL images
				__A    =							prepare_image_inputs(self.image_processor_tester							, equal_resolution=lowercase__						)
				for image in image_inputs:
						self.assertIsInstance(lowercase__							, Image.Image						)

				# Test not batched input
				__A    =							image_processing(image_inputs[0]							, return_tensors="pt"						).pixel_values
				self.assertEqual(
				    encoded_images.shape							, (
				        1,
				        self.image_processor_tester.num_channels,
				        self.image_processor_tester.size["height"],
				        self.image_processor_tester.size["width"],
				    )							, )

				# Test batched
				__A    =							image_processing(lowercase__							, return_tensors="pt"						).pixel_values
				self.assertEqual(
				    encoded_images.shape							, (
				        self.image_processor_tester.batch_size,
				        self.image_processor_tester.num_channels,
				        self.image_processor_tester.size["height"],
				        self.image_processor_tester.size["width"],
				    )							, )






		def 					_lowerCamelCase					(      self						)				->				List[str]:
				# Initialize image_processing
				__A    =							self.image_processing_class(**self.image_processor_dict						)
				# create random numpy tensors
				__A    =							prepare_image_inputs(self.image_processor_tester							, equal_resolution=lowercase__							, numpify=lowercase__						)
				for image in image_inputs:
						self.assertIsInstance(lowercase__							, np.ndarray						)

				# Test not batched input
				__A    =							image_processing(image_inputs[0]							, return_tensors="pt"						).pixel_values
				self.assertEqual(
				    encoded_images.shape							, (
				        1,
				        self.image_processor_tester.num_channels,
				        self.image_processor_tester.size["height"],
				        self.image_processor_tester.size["width"],
				    )							, )

				# Test batched
				__A    =							image_processing(lowercase__							, return_tensors="pt"						).pixel_values
				self.assertEqual(
				    encoded_images.shape							, (
				        self.image_processor_tester.batch_size,
				        self.image_processor_tester.num_channels,
				        self.image_processor_tester.size["height"],
				        self.image_processor_tester.size["width"],
				    )							, )






		def 					_lowerCamelCase					(      self						)				->				List[str]:
				# Initialize image_processing
				__A    =							self.image_processing_class(**self.image_processor_dict						)
				# create random PyTorch tensors
				__A    =							prepare_image_inputs(self.image_processor_tester							, equal_resolution=lowercase__							, torchify=lowercase__						)
				for image in image_inputs:
						self.assertIsInstance(lowercase__							, torch.Tensor						)

				# Test not batched input
				__A    =							image_processing(image_inputs[0]							, return_tensors="pt"						).pixel_values
				self.assertEqual(
				    encoded_images.shape							, (
				        1,
				        self.image_processor_tester.num_channels,
				        self.image_processor_tester.size["height"],
				        self.image_processor_tester.size["width"],
				    )							, )

				# Test batched
				__A    =							image_processing(lowercase__							, return_tensors="pt"						).pixel_values
				self.assertEqual(
				    encoded_images.shape							, (
				        self.image_processor_tester.batch_size,
				        self.image_processor_tester.num_channels,
				        self.image_processor_tester.size["height"],
				        self.image_processor_tester.size["width"],
				    )							, )






		def 					_lowerCamelCase					(      self						)				->				Dict:
				# Initialize image_processing
				__A    =							self.image_processing_class(**self.image_processor_dict						)
				# create random PyTorch tensors
				__A    =							prepare_image_inputs(self.image_processor_tester							, equal_resolution=lowercase__							, torchify=lowercase__						)
				__A    =							[]
				for image in image_inputs:
						self.assertIsInstance(lowercase__							, torch.Tensor						)
						maps.append(torch.zeros(image.shape[-2:]						).long()						)

				# Test not batched input
				__A    =							image_processing(image_inputs[0]							, maps[0]							, return_tensors="pt"						)
				self.assertEqual(
				    encoding["pixel_values"].shape							, (
				        1,
				        self.image_processor_tester.num_channels,
				        self.image_processor_tester.size["height"],
				        self.image_processor_tester.size["width"],
				    )							, )
				self.assertEqual(
				    encoding["labels"].shape							, (
				        1,
				        self.image_processor_tester.size["height"],
				        self.image_processor_tester.size["width"],
				    )							, )
				self.assertEqual(encoding["labels"].dtype							, torch.long						)
				self.assertTrue(encoding["labels"].min().item() >= 0						)
				self.assertTrue(encoding["labels"].max().item() <= 255						)

				# Test batched
				__A    =							image_processing(lowercase__							, lowercase__							, return_tensors="pt"						)
				self.assertEqual(
				    encoding["pixel_values"].shape							, (
				        self.image_processor_tester.batch_size,
				        self.image_processor_tester.num_channels,
				        self.image_processor_tester.size["height"],
				        self.image_processor_tester.size["width"],
				    )							, )
				self.assertEqual(
				    encoding["labels"].shape							, (
				        self.image_processor_tester.batch_size,
				        self.image_processor_tester.size["height"],
				        self.image_processor_tester.size["width"],
				    )							, )
				self.assertEqual(encoding["labels"].dtype							, torch.long						)
				self.assertTrue(encoding["labels"].min().item() >= 0						)
				self.assertTrue(encoding["labels"].max().item() <= 255						)

				# Test not batched input (PIL images)
				__A ,   __A    =							prepare_semantic_single_inputs()

				__A    =							image_processing(lowercase__							, lowercase__							, return_tensors="pt"						)
				self.assertEqual(
				    encoding["pixel_values"].shape							, (
				        1,
				        self.image_processor_tester.num_channels,
				        self.image_processor_tester.size["height"],
				        self.image_processor_tester.size["width"],
				    )							, )
				self.assertEqual(
				    encoding["labels"].shape							, (
				        1,
				        self.image_processor_tester.size["height"],
				        self.image_processor_tester.size["width"],
				    )							, )
				self.assertEqual(encoding["labels"].dtype							, torch.long						)
				self.assertTrue(encoding["labels"].min().item() >= 0						)
				self.assertTrue(encoding["labels"].max().item() <= 255						)

				# Test batched input (PIL images)
				__A ,   __A    =							prepare_semantic_batch_inputs()

				__A    =							image_processing(lowercase__							, lowercase__							, return_tensors="pt"						)
				self.assertEqual(
				    encoding["pixel_values"].shape							, (
				        2,
				        self.image_processor_tester.num_channels,
				        self.image_processor_tester.size["height"],
				        self.image_processor_tester.size["width"],
				    )							, )
				self.assertEqual(
				    encoding["labels"].shape							, (
				        2,
				        self.image_processor_tester.size["height"],
				        self.image_processor_tester.size["width"],
				    )							, )
				self.assertEqual(encoding["labels"].dtype							, torch.long						)
				self.assertTrue(encoding["labels"].min().item() >= 0						)
				self.assertTrue(encoding["labels"].max().item() <= 255						)






		def 					_lowerCamelCase					(      self						)				->				Tuple:
				# Initialize image_processing
				__A    =							self.image_processing_class(**self.image_processor_dict						)

				# ADE20k has 150 classes, and the background is included, so labels should be between 0 and 150
				__A ,   __A    =							prepare_semantic_single_inputs()
				__A    =							image_processing(lowercase__							, lowercase__							, return_tensors="pt"						)
				self.assertTrue(encoding["labels"].min().item() >= 0						)
				self.assertTrue(encoding["labels"].max().item() <= 150						)

				__A    =							True
				__A    =							image_processing(lowercase__							, lowercase__							, return_tensors="pt"						)
				self.assertTrue(encoding["labels"].min().item() >= 0						)
				self.assertTrue(encoding["labels"].max().item() <= 255						)

