






"""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     __UpperCAmelCase:




						"""simple docstring"""




						def __init__(   self       ,  snake_case__       ,  snake_case__=3       ,  snake_case__=32       ,  snake_case__=3       ,  snake_case__=10       ,  snake_case__=[10, 20, 30, 40]       ,  snake_case__=[1, 1, 2, 1]       ,  snake_case__=True       ,  snake_case__=True       ,  snake_case__="relu"       ,  snake_case__=3       ,  snake_case__=None       ,  snake_case__=["stage2", "stage3", "stage4"]       ,  snake_case__=[2, 3, 4]       ,  ):
												'''simple docstring'''
												lowercase__				:      Any=       parent
												lowercase__				:      List[Any]=       batch_size
												lowercase__				:      Tuple=       image_size
												lowercase__				:      str=       num_channels
												lowercase__				:      Tuple=       embeddings_size
												lowercase__				:      Optional[Any]=       hidden_sizes
												lowercase__				:      List[str]=       depths
												lowercase__				:      Dict=       is_training
												lowercase__				:      Tuple=       use_labels
												lowercase__				:      List[Any]=       hidden_act
												lowercase__				:      Optional[Any]=       num_labels
												lowercase__				:      Optional[Any]=       scope
												lowercase__				:      str=       len(snake_case__			)
												lowercase__				:      int=       out_features
												lowercase__				:      List[str]=       out_indices




						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												lowercase__				:      Any=       floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]			)

												lowercase__				:      List[Any]=       None
												if self.use_labels:
																		lowercase__				:      Optional[Any]=       ids_tensor([self.batch_size]       ,  self.num_labels			)

												lowercase__				:      Union[str, Any]=       self.get_config()

												return config, pixel_values, labels




						def 		UpperCAmelCase_       (   self			):
												'''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       ,  snake_case__       ,  snake_case__       ,  snake_case__			):
												'''simple docstring'''
												lowercase__				:      int=       ResNetModel(config=snake_case__			)
												model.to(snake_case__			)
												model.eval()
												lowercase__				:      Tuple=       model(snake_case__			)
												# 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       ,  snake_case__       ,  snake_case__       ,  snake_case__			):
												'''simple docstring'''
												lowercase__				:      Any=       self.num_labels
												lowercase__				:      List[str]=       ResNetForImageClassification(snake_case__			)
												model.to(snake_case__			)
												model.eval()
												lowercase__				:      int=       model(snake_case__       ,  labels=snake_case__			)
												self.parent.assertEqual(result.logits.shape       ,  (self.batch_size, self.num_labels)			)




						def 		UpperCAmelCase_       (   self       ,  snake_case__       ,  snake_case__       ,  snake_case__			):
												'''simple docstring'''
												lowercase__				:      List[Any]=       ResNetBackbone(config=snake_case__			)
												model.to(snake_case__			)
												model.eval()
												lowercase__				:      int=       model(snake_case__			)

												# 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
												lowercase__				:      str=       None
												lowercase__				:      Optional[Any]=       ResNetBackbone(config=snake_case__			)
												model.to(snake_case__			)
												model.eval()
												lowercase__				:      Dict=       model(snake_case__			)

												# 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			):
												'''simple docstring'''
												lowercase__				:      int=       self.prepare_config_and_inputs()
												lowercase__,	lowercase__,	lowercase__				:      Optional[int]=       config_and_inputs
												lowercase__				:      Optional[Any]=       {"pixel_values": pixel_values}
												return config, inputs_dict


@require_torch
class     __UpperCAmelCase(   SCREAMING_SNAKE_CASE__  ,  SCREAMING_SNAKE_CASE__  ,  unittest.TestCase							):




						"""simple docstring"""




						__lowerCamelCase				       =					(
						    (
						        ResNetModel,
						        ResNetForImageClassification,
						        ResNetBackbone,
						    )
						    if is_torch_available()
						    else ()
						)
						__lowerCamelCase				       =					(
						    {"feature-extraction": ResNetModel, "image-classification": ResNetForImageClassification}
						    if is_torch_available()
						    else {}
						)

						__lowerCamelCase				       =					True
						__lowerCamelCase				       =					False
						__lowerCamelCase				       =					False
						__lowerCamelCase				       =					False
						__lowerCamelCase				       =					False




						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												lowercase__				:      List[str]=       ResNetModelTester(self			)
												lowercase__				:      Any=       ConfigTester(self       ,  config_class=snake_case__       ,  has_text_modality=snake_case__			)




						def 		UpperCAmelCase_       (   self			):
												'''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			):
												'''simple docstring'''
												return




						@unittest.skip(reason="ResNet does not use inputs_embeds"			)
						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												pass




						@unittest.skip(reason="ResNet does not support input and output embeddings"			)
						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												pass




						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												lowercase__,	lowercase__				:      int=       self.model_tester.prepare_config_and_inputs_for_common()

												for model_class in self.all_model_classes:
																		lowercase__				:      int=       model_class(snake_case__			)
																		lowercase__				:      Union[str, Any]=       inspect.signature(model.forward			)
																		# signature.parameters is an OrderedDict => so arg_names order is deterministic
																		lowercase__				:      Optional[int]=       [*signature.parameters.keys()]

																		lowercase__				:      Dict=       ["pixel_values"]
																		self.assertListEqual(arg_names[:1]       ,  snake_case__			)




						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												lowercase__				:      Union[str, Any]=       self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_model(*snake_case__			)




						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												lowercase__				:      str=       self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_backbone(*snake_case__			)




						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												lowercase__,	lowercase__				:      Optional[Any]=       self.model_tester.prepare_config_and_inputs_for_common()

												for model_class in self.all_model_classes:
																		lowercase__				:      Any=       model_class(config=snake_case__			)
																		for name, module in model.named_modules():
																								if isinstance(snake_case__       ,  (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			):
												'''simple docstring'''
												def check_hidden_states_output(snake_case__       ,  snake_case__       ,  snake_case__			):
																		lowercase__				:      Tuple=       model_class(snake_case__			)
																		model.to(snake_case__			)
																		model.eval()

																		with torch.no_grad():
																								lowercase__				:      Optional[int]=       model(**self._prepare_for_class(snake_case__       ,  snake_case__			)			)

																		lowercase__				:      Tuple=       outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states

																		lowercase__				:      int=       self.model_tester.num_stages
																		self.assertEqual(len(snake_case__			)       ,  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]       ,  )

												lowercase__,	lowercase__				:      Optional[int]=       self.model_tester.prepare_config_and_inputs_for_common()
												lowercase__				:      Union[str, Any]=       ["basic", "bottleneck"]
												for model_class in self.all_model_classes:
																		for layer_type in layers_type:
																								lowercase__				:      Union[str, Any]=       layer_type
																								lowercase__				:      List[str]=       True
																								check_hidden_states_output(snake_case__       ,  snake_case__       ,  snake_case__			)

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

																								check_hidden_states_output(snake_case__       ,  snake_case__       ,  snake_case__			)




						@unittest.skip(reason="ResNet does not use feedforward chunking"			)
						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												pass




						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												lowercase__				:      Tuple=       self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_for_image_classification(*snake_case__			)




						@slow
						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												for model_name in RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																		lowercase__				:      int=       ResNetModel.from_pretrained(snake_case__			)
																		self.assertIsNotNone(snake_case__			)





def 						lowercase__()				->Any:




						"""simple docstring"""



						lowercase__				:      List[Any]=       Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"						)
						return image


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




						"""simple docstring"""




						@cached_property
						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												return (
												    AutoImageProcessor.from_pretrained(RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[0]			)
												    if is_vision_available()
												    else None
												)




						@slow
						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												lowercase__				:      List[str]=       ResNetForImageClassification.from_pretrained(RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[0]			).to(snake_case__			)

												lowercase__				:      str=       self.default_image_processor
												lowercase__				:      Tuple=       prepare_img()
												lowercase__				:      int=       image_processor(images=snake_case__       ,  return_tensors="pt"			).to(snake_case__			)

												# forward pass
												with torch.no_grad():
																		lowercase__				:      Dict=       model(**snake_case__			)

												# verify the logits
												lowercase__				:      Dict=       torch.Size((1, 1000)			)
												self.assertEqual(outputs.logits.shape       ,  snake_case__			)

												lowercase__				:      List[Any]=       torch.tensor([-11.10_69, -9.78_77, -8.37_77]			).to(snake_case__			)

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


@require_torch
class     __UpperCAmelCase(   SCREAMING_SNAKE_CASE__  ,  unittest.TestCase							):




						"""simple docstring"""




						__lowerCamelCase				       =					(ResNetBackbone,) if is_torch_available() else ()
						__lowerCamelCase				       =					False
						__lowerCamelCase				       =					ResNetConfig




						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												lowercase__				:      Dict=       ResNetModelTester(self			)














"""simple docstring"""







import unittest

import numpy as np

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


if is_torch_available():
			import torch

if is_vision_available():
			from PIL import Image

			from transformers import CLIPImageProcessor


class     __UpperCAmelCase(   unittest.TestCase							):




						"""simple docstring"""




						def __init__(   self       ,  snake_case__       ,  snake_case__=7       ,  snake_case__=3       ,  snake_case__=18       ,  snake_case__=30       ,  snake_case__=400       ,  snake_case__=True       ,  snake_case__=None       ,  snake_case__=True       ,  snake_case__=None       ,  snake_case__=True       ,  snake_case__=[0.48_14_54_66, 0.4_57_82_75, 0.40_82_10_73]       ,  snake_case__=[0.26_86_29_54, 0.26_13_02_58, 0.27_57_77_11]       ,  snake_case__=True       ,  ):
												'''simple docstring'''
												lowercase__				:      int=       size if size is not None else {"shortest_edge": 20}
												lowercase__				:      int=       crop_size if crop_size is not None else {"height": 18, "width": 18}
												lowercase__				:      Union[str, Any]=       parent
												lowercase__				:      Optional[Any]=       batch_size
												lowercase__				:      List[str]=       num_channels
												lowercase__				:      str=       image_size
												lowercase__				:      Optional[int]=       min_resolution
												lowercase__				:      Union[str, Any]=       max_resolution
												lowercase__				:      List[Any]=       do_resize
												lowercase__				:      Any=       size
												lowercase__				:      Optional[Any]=       do_center_crop
												lowercase__				:      List[str]=       crop_size
												lowercase__				:      List[Any]=       do_normalize
												lowercase__				:      Optional[Any]=       image_mean
												lowercase__				:      Dict=       image_std
												lowercase__				:      Dict=       do_convert_rgb




						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												return {
												    "do_resize": self.do_resize,
												    "size": self.size,
												    "do_center_crop": self.do_center_crop,
												    "crop_size": self.crop_size,
												    "do_normalize": self.do_normalize,
												    "image_mean": self.image_mean,
												    "image_std": self.image_std,
												    "do_convert_rgb": self.do_convert_rgb,
												}




						def 		UpperCAmelCase_       (   self       ,  snake_case__=False       ,  snake_case__=False       ,  snake_case__=False			):
												'''simple docstring'''
												assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

												if equal_resolution:
																		lowercase__				:      Optional[Any]=       []
																		for i in range(self.batch_size			):
																								image_inputs.append(
																								    np.random.randint(
																								        255       ,  size=(self.num_channels, self.max_resolution, self.max_resolution)       ,  dtype=np.uinta			)			)
												else:
																		lowercase__				:      Optional[Any]=       []
																		for i in range(self.batch_size			):
																								lowercase__,	lowercase__				:      str=       np.random.choice(np.arange(self.min_resolution       ,  self.max_resolution			)       ,  2			)
																								image_inputs.append(np.random.randint(255       ,  size=(self.num_channels, width, height)       ,  dtype=np.uinta			)			)

												if not numpify and not torchify:
																		# PIL expects the channel dimension as last dimension
																		lowercase__				:      Dict=       [Image.fromarray(np.moveaxis(snake_case__       ,  0       ,  -1			)			) for x in image_inputs]

												if torchify:
																		lowercase__				:      Tuple=       [torch.from_numpy(snake_case__			) for x in image_inputs]

												return image_inputs


@require_torch
@require_vision
class     __UpperCAmelCase(   SCREAMING_SNAKE_CASE__  ,  unittest.TestCase							):




						"""simple docstring"""




						__lowerCamelCase				       =					CLIPImageProcessor if is_vision_available() else None




						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												lowercase__				:      List[Any]=       CLIPImageProcessingTester(self			)




						@property
						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												return self.image_processor_tester.prepare_image_processor_dict()




						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												lowercase__				:      Dict=       self.image_processing_class(**self.image_processor_dict			)
												self.assertTrue(hasattr(snake_case__       ,  "do_resize"			)			)
												self.assertTrue(hasattr(snake_case__       ,  "size"			)			)
												self.assertTrue(hasattr(snake_case__       ,  "do_center_crop"			)			)
												self.assertTrue(hasattr(snake_case__       ,  "center_crop"			)			)
												self.assertTrue(hasattr(snake_case__       ,  "do_normalize"			)			)
												self.assertTrue(hasattr(snake_case__       ,  "image_mean"			)			)
												self.assertTrue(hasattr(snake_case__       ,  "image_std"			)			)
												self.assertTrue(hasattr(snake_case__       ,  "do_convert_rgb"			)			)




						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												lowercase__				:      List[str]=       self.image_processing_class.from_dict(self.image_processor_dict			)
												self.assertEqual(image_processor.size       ,  {"shortest_edge": 20}			)
												self.assertEqual(image_processor.crop_size       ,  {"height": 18, "width": 18}			)

												lowercase__				:      Dict=       self.image_processing_class.from_dict(self.image_processor_dict       ,  size=42       ,  crop_size=84			)
												self.assertEqual(image_processor.size       ,  {"shortest_edge": 42}			)
												self.assertEqual(image_processor.crop_size       ,  {"height": 84, "width": 84}			)




						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												pass




						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												# Initialize image_processing
												lowercase__				:      int=       self.image_processing_class(**self.image_processor_dict			)
												# create random PIL images
												lowercase__				:      Optional[Any]=       self.image_processor_tester.prepare_inputs(equal_resolution=snake_case__			)
												for image in image_inputs:
																		self.assertIsInstance(snake_case__       ,  Image.Image			)

												# Test not batched input
												lowercase__				:      List[str]=       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.crop_size["height"],
												        self.image_processor_tester.crop_size["width"],
												    )       ,  )

												# Test batched
												lowercase__				:      Dict=       image_processing(snake_case__       ,  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.crop_size["height"],
												        self.image_processor_tester.crop_size["width"],
												    )       ,  )




						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												# Initialize image_processing
												lowercase__				:      Any=       self.image_processing_class(**self.image_processor_dict			)
												# create random numpy tensors
												lowercase__				:      Tuple=       self.image_processor_tester.prepare_inputs(equal_resolution=snake_case__       ,  numpify=snake_case__			)
												for image in image_inputs:
																		self.assertIsInstance(snake_case__       ,  np.ndarray			)

												# Test not batched input
												lowercase__				:      Dict=       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.crop_size["height"],
												        self.image_processor_tester.crop_size["width"],
												    )       ,  )

												# Test batched
												lowercase__				:      int=       image_processing(snake_case__       ,  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.crop_size["height"],
												        self.image_processor_tester.crop_size["width"],
												    )       ,  )




						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												# Initialize image_processing
												lowercase__				:      Optional[Any]=       self.image_processing_class(**self.image_processor_dict			)
												# create random PyTorch tensors
												lowercase__				:      Union[str, Any]=       self.image_processor_tester.prepare_inputs(equal_resolution=snake_case__       ,  torchify=snake_case__			)
												for image in image_inputs:
																		self.assertIsInstance(snake_case__       ,  torch.Tensor			)

												# Test not batched input
												lowercase__				:      Any=       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.crop_size["height"],
												        self.image_processor_tester.crop_size["width"],
												    )       ,  )

												# Test batched
												lowercase__				:      Union[str, Any]=       image_processing(snake_case__       ,  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.crop_size["height"],
												        self.image_processor_tester.crop_size["width"],
												    )       ,  )


@require_torch
@require_vision
class     __UpperCAmelCase(   SCREAMING_SNAKE_CASE__  ,  unittest.TestCase							):




						"""simple docstring"""




						__lowerCamelCase				       =					CLIPImageProcessor if is_vision_available() else None




						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												lowercase__				:      Optional[int]=       CLIPImageProcessingTester(self       ,  num_channels=4			)
												lowercase__				:      Optional[Any]=       3




						@property
						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												return self.image_processor_tester.prepare_image_processor_dict()




						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												lowercase__				:      List[str]=       self.image_processing_class(**self.image_processor_dict			)
												self.assertTrue(hasattr(snake_case__       ,  "do_resize"			)			)
												self.assertTrue(hasattr(snake_case__       ,  "size"			)			)
												self.assertTrue(hasattr(snake_case__       ,  "do_center_crop"			)			)
												self.assertTrue(hasattr(snake_case__       ,  "center_crop"			)			)
												self.assertTrue(hasattr(snake_case__       ,  "do_normalize"			)			)
												self.assertTrue(hasattr(snake_case__       ,  "image_mean"			)			)
												self.assertTrue(hasattr(snake_case__       ,  "image_std"			)			)
												self.assertTrue(hasattr(snake_case__       ,  "do_convert_rgb"			)			)




						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												pass




						def 		UpperCAmelCase_       (   self			):
												'''simple docstring'''
												# Initialize image_processing
												lowercase__				:      int=       self.image_processing_class(**self.image_processor_dict			)
												# create random PIL images
												lowercase__				:      int=       self.image_processor_tester.prepare_inputs(equal_resolution=snake_case__			)
												for image in image_inputs:
																		self.assertIsInstance(snake_case__       ,  Image.Image			)

												# Test not batched input
												lowercase__				:      Optional[int]=       image_processing(image_inputs[0]       ,  return_tensors="pt"			).pixel_values
												self.assertEqual(
												    encoded_images.shape       ,  (
												        1,
												        self.expected_encoded_image_num_channels,
												        self.image_processor_tester.crop_size["height"],
												        self.image_processor_tester.crop_size["width"],
												    )       ,  )

												# Test batched
												lowercase__				:      Any=       image_processing(snake_case__       ,  return_tensors="pt"			).pixel_values
												self.assertEqual(
												    encoded_images.shape       ,  (
												        self.image_processor_tester.batch_size,
												        self.expected_encoded_image_num_channels,
												        self.image_processor_tester.crop_size["height"],
												        self.image_processor_tester.crop_size["width"],
												    )       ,  )






