



import inspect
import unittest

from transformers import DataaVecVisionConfig
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

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


if is_torch_available():
			import torch
			from torch import nn

			from transformers import (
			    MODEL_MAPPING,
			    DataaVecVisionForImageClassification,
			    DataaVecVisionForSemanticSegmentation,
			    DataaVecVisionModel,
			)
			from transformers.models.dataavec.modeling_dataavec_vision import DATA2VEC_VISION_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
			from PIL import Image

			from transformers import BeitImageProcessor
class       _lowerCAmelCase :






			"""simple docstring"""





			def __init__(					self						:							Any      ,  lowercase						:							Union[str, Any]      ,  lowercase						:							str=100      ,  lowercase						:							Any=13      ,  lowercase						:							Dict=30      ,  lowercase						:							Union[str, Any]=2      ,  lowercase						:							Tuple=3      ,  lowercase						:							Tuple=True      ,  lowercase						:							str=True      ,  lowercase						:							Dict=32      ,  lowercase						:							List[Any]=4      ,  lowercase						:							Dict=4      ,  lowercase						:							Tuple=37      ,  lowercase						:							Optional[int]="gelu"      ,  lowercase						:							str=0.1      ,  lowercase						:							List[str]=0.1      ,  lowercase						:							Dict=10      ,  lowercase						:							Dict=0.02      ,  lowercase						:							Optional[Any]=3      ,  lowercase						:							Dict=None      ,  lowercase						:							Optional[int]=[0, 1, 2, 3]      ,  )    ->       Dict:
									"""simple docstring"""







									__lowercase											=					parent
									__lowercase											=					100
									__lowercase											=					batch_size
									__lowercase											=					image_size
									__lowercase											=					patch_size
									__lowercase											=					num_channels
									__lowercase											=					is_training
									__lowercase											=					use_labels
									__lowercase											=					hidden_size
									__lowercase											=					num_hidden_layers
									__lowercase											=					num_attention_heads
									__lowercase											=					intermediate_size
									__lowercase											=					hidden_act
									__lowercase											=					hidden_dropout_prob
									__lowercase											=					attention_probs_dropout_prob
									__lowercase											=					type_sequence_label_size
									__lowercase											=					initializer_range
									__lowercase											=					scope
									__lowercase											=					out_indices
									__lowercase											=					num_labels

									# in BeiT, the seq length equals the number of patches + 1 (we add 1 for the [CLS] token)
									__lowercase											=					(image_size // patch_size) ** 2
									__lowercase											=					num_patches + 1





			def 		snake_case__      (					self						:							List[Any] )    ->       List[Any]:
									"""simple docstring"""







									__lowercase											=					floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size] )

									__lowercase											=					None
									__lowercase											=					None
									if self.use_labels:
															__lowercase											=					ids_tensor([self.batch_size]      ,  self.type_sequence_label_size )
															__lowercase											=					ids_tensor([self.batch_size, self.image_size, self.image_size]      ,  self.num_labels )

									__lowercase											=					self.get_config()

									return config, pixel_values, labels, pixel_labels





			def 		snake_case__      (					self						:							Union[str, Any] )    ->       str:
									"""simple docstring"""







									return DataaVecVisionConfig(
									    vocab_size=self.vocab_size      ,  image_size=self.image_size      ,  patch_size=self.patch_size      ,  num_channels=self.num_channels      ,  hidden_size=self.hidden_size      ,  num_hidden_layers=self.num_hidden_layers      ,  num_attention_heads=self.num_attention_heads      ,  intermediate_size=self.intermediate_size      ,  hidden_act=self.hidden_act      ,  hidden_dropout_prob=self.hidden_dropout_prob      ,  attention_probs_dropout_prob=self.attention_probs_dropout_prob      ,  is_decoder=_UpperCAmelCase      ,  initializer_range=self.initializer_range      ,  out_indices=self.out_indices      ,  )





			def 		snake_case__      (					self						:							Optional[Any]      ,  lowercase						:							Optional[Any]      ,  lowercase						:							int      ,  lowercase						:							Any      ,  lowercase						:							List[str] )    ->       Union[str, Any]:
									"""simple docstring"""







									__lowercase											=					DataaVecVisionModel(config=_UpperCAmelCase )
									model.to(_UpperCAmelCase )
									model.eval()
									__lowercase											=					model(_UpperCAmelCase )
									# expected sequence length = num_patches + 1 (we add 1 for the [CLS] token)
									__lowercase											=					(self.image_size // self.patch_size) ** 2
									self.parent.assertEqual(result.last_hidden_state.shape      ,  (self.batch_size, num_patches + 1, self.hidden_size) )





			def 		snake_case__      (					self						:							Dict      ,  lowercase						:							Dict      ,  lowercase						:							Tuple      ,  lowercase						:							Any      ,  lowercase						:							Tuple )    ->       Any:
									"""simple docstring"""







									__lowercase											=					self.type_sequence_label_size
									__lowercase											=					DataaVecVisionForImageClassification(_UpperCAmelCase )
									model.to(_UpperCAmelCase )
									model.eval()
									__lowercase											=					model(_UpperCAmelCase      ,  labels=_UpperCAmelCase )
									self.parent.assertEqual(result.logits.shape      ,  (self.batch_size, self.type_sequence_label_size) )





			def 		snake_case__      (					self						:							int      ,  lowercase						:							List[Any]      ,  lowercase						:							Dict      ,  lowercase						:							Optional[int]      ,  lowercase						:							int )    ->       str:
									"""simple docstring"""







									__lowercase											=					self.num_labels
									__lowercase											=					DataaVecVisionForSemanticSegmentation(_UpperCAmelCase )
									model.to(_UpperCAmelCase )
									model.eval()
									__lowercase											=					model(_UpperCAmelCase )
									self.parent.assertEqual(
									    result.logits.shape      ,  (self.batch_size, self.num_labels, self.image_size * 2, self.image_size * 2) )
									__lowercase											=					model(_UpperCAmelCase      ,  labels=_UpperCAmelCase )
									self.parent.assertEqual(
									    result.logits.shape      ,  (self.batch_size, self.num_labels, self.image_size * 2, self.image_size * 2) )







			def 		snake_case__      (					self						:							Dict )    ->       List[Any]:
									"""simple docstring"""







									__lowercase											=					self.prepare_config_and_inputs()
									__lowercase						,      __lowercase						,      __lowercase						,      __lowercase											=					config_and_inputs
									__lowercase											=					{"""pixel_values""": pixel_values}
									return config, inputs_dict





@require_torch
class       _lowerCAmelCase (			_UpperCAmelCase     ,       _UpperCAmelCase     ,       unittest.TestCase      ):






			"""simple docstring"""





			lowercase__   :	Optional[int]  			=      (
			    (DataaVecVisionModel, DataaVecVisionForImageClassification, DataaVecVisionForSemanticSegmentation)
			    if is_torch_available()
			    else ()
			)
			lowercase__   :	str  			=      (
			    {
			        '''feature-extraction''': DataaVecVisionModel,
			        '''image-classification''': DataaVecVisionForImageClassification,
			        '''image-segmentation''': DataaVecVisionForSemanticSegmentation,
			    }
			    if is_torch_available()
			    else {}
			)

			lowercase__   :	Any  			=      False
			lowercase__   :	List[str]  			=      False
			lowercase__   :	int  			=      False





			def 		snake_case__      (					self						:							Tuple )    ->       Any:
									"""simple docstring"""







									__lowercase											=					DataaVecVisionModelTester(self )
									__lowercase											=					ConfigTester(
									    self      ,  config_class=_UpperCAmelCase      ,  has_text_modality=_UpperCAmelCase      ,  hidden_size=37 )





			def 		snake_case__      (					self						:							str )    ->       int:
									"""simple docstring"""







									self.config_tester.run_common_tests()





			def 		snake_case__      (					self						:							str )    ->       Dict:
									"""simple docstring"""







									pass





			@require_torch_multi_gpu
			@unittest.skip(
			    reason="""Data2VecVision has some layers using `add_module` which doesn't work well with `nn.DataParallel`""" )
			def 		snake_case__      (					self						:							Any )    ->       Dict:
									"""simple docstring"""







									pass





			def 		snake_case__      (					self						:							List[Any] )    ->       Optional[Any]:
									"""simple docstring"""







									__lowercase						,      __lowercase											=					self.model_tester.prepare_config_and_inputs_for_common()

									for model_class in self.all_model_classes:
															__lowercase											=					model_class(_UpperCAmelCase )
															self.assertIsInstance(model.get_input_embeddings()      ,  (nn.Module) )
															__lowercase											=					model.get_output_embeddings()
															self.assertTrue(x is None or isinstance(_UpperCAmelCase      ,  nn.Linear ) )





			def 		snake_case__      (					self						:							Tuple )    ->       Union[str, Any]:
									"""simple docstring"""







									__lowercase						,      __lowercase											=					self.model_tester.prepare_config_and_inputs_for_common()

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

															__lowercase											=					["""pixel_values"""]
															self.assertListEqual(arg_names[:1]      ,  _UpperCAmelCase )





			def 		snake_case__      (					self						:							Optional[int] )    ->       str:
									"""simple docstring"""







									__lowercase											=					self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_model(*_UpperCAmelCase )





			def 		snake_case__      (					self						:							int )    ->       Optional[Any]:
									"""simple docstring"""







									__lowercase											=					self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_image_segmentation(*_UpperCAmelCase )





			def 		snake_case__      (					self						:							List[Any] )    ->       Optional[Any]:
									"""simple docstring"""







									if not self.model_tester.is_training:
															return

									__lowercase						,      __lowercase											=					self.model_tester.prepare_config_and_inputs_for_common()
									__lowercase											=					True

									for model_class in self.all_model_classes:
															if model_class in [*get_values(_UpperCAmelCase )]:
																					continue

															__lowercase											=					model_class(_UpperCAmelCase )
															model.to(_UpperCAmelCase )
															model.train()
															__lowercase											=					self._prepare_for_class(_UpperCAmelCase      ,  _UpperCAmelCase      ,  return_labels=_UpperCAmelCase )
															__lowercase											=					model(**_UpperCAmelCase ).loss
															loss.backward()





			def 		snake_case__      (					self						:							Any )    ->       int:
									"""simple docstring"""







									__lowercase						,      __lowercase											=					self.model_tester.prepare_config_and_inputs_for_common()
									if not self.model_tester.is_training:
															return

									__lowercase											=					False
									__lowercase											=					True

									for model_class in self.all_model_classes:
															if model_class in [*get_values(_UpperCAmelCase )] or not model_class.supports_gradient_checkpointing:
																					continue
															# TODO: remove the following 3 lines once we have a MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING
															# this can then be incorporated into _prepare_for_class in test_modeling_common.py
															elif model_class.__name__ == "Data2VecVisionForSemanticSegmentation":
																					__lowercase						,      __lowercase						,      __lowercase						,      __lowercase											=					inputs_dict["""pixel_values"""].shape
																					__lowercase											=					torch.zeros(
																					    [self.model_tester.batch_size, height, width]      ,  device=_UpperCAmelCase ).long()
															__lowercase											=					model_class(_UpperCAmelCase )
															model.gradient_checkpointing_enable()
															model.to(_UpperCAmelCase )
															model.train()
															__lowercase											=					self._prepare_for_class(_UpperCAmelCase      ,  _UpperCAmelCase      ,  return_labels=_UpperCAmelCase )
															__lowercase											=					model(**_UpperCAmelCase ).loss
															loss.backward()





			def 		snake_case__      (					self						:							str )    ->       Optional[Any]:
									"""simple docstring"""







									__lowercase						,      __lowercase											=					self.model_tester.prepare_config_and_inputs_for_common()

									__lowercase											=					_config_zero_init(_UpperCAmelCase )
									for model_class in self.all_model_classes:
															__lowercase											=					model_class(config=_UpperCAmelCase )
															for name, param in model.named_parameters():
																					# we skip lambda parameters as these require special initial values
																					# determined by config.layer_scale_init_value
																					if "lambda" in name:
																											continue
																					if param.requires_grad:
																											self.assertIn(
																											    ((param.data.mean() * 1E9).round() / 1E9).item()      ,  [0.0, 1.0]      ,  msg=F"Parameter {name} of model {model_class} seems not properly initialized"      ,  )





			def 		snake_case__      (					self						:							Optional[int]      ,  lowercase						:							Dict      ,  lowercase						:							List[Any]      ,  lowercase						:							Union[str, Any]      ,  lowercase						:							Dict=2E-4      ,  lowercase						:							int="outputs"      ,  lowercase						:							Optional[Any]=None )    ->       int:
									"""simple docstring"""







									super().check_pt_tf_outputs(_UpperCAmelCase      ,  _UpperCAmelCase      ,  _UpperCAmelCase      ,  _UpperCAmelCase      ,  _UpperCAmelCase      ,  _UpperCAmelCase )





			def 		snake_case__      (					self						:							List[Any] )    ->       Dict:
									"""simple docstring"""







									__lowercase											=					self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_image_classification(*_UpperCAmelCase )







			@slow
			def 		snake_case__      (					self						:							Tuple )    ->       List[Any]:
									"""simple docstring"""







									for model_name in DATA2VEC_VISION_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
															__lowercase											=					DataaVecVisionModel.from_pretrained(_UpperCAmelCase )
															self.assertIsNotNone(_UpperCAmelCase )






def 			UpperCAmelCase__     (     )			->   int:
						__lowercase											=					Image.open("""./tests/fixtures/tests_samples/COCO/000000039769.png""" )
						return image







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






			"""simple docstring"""





			@cached_property
			def 		snake_case__      (					self						:							Tuple )    ->       List[str]:
									"""simple docstring"""







									return (
									    BeitImageProcessor.from_pretrained("""facebook/data2vec-vision-base-ft1k""" ) if is_vision_available() else None
									)







			@slow
			def 		snake_case__      (					self						:							Union[str, Any] )    ->       Optional[int]:
									"""simple docstring"""







									__lowercase											=					DataaVecVisionForImageClassification.from_pretrained("""facebook/data2vec-vision-base-ft1k""" ).to(
									    _UpperCAmelCase )

									__lowercase											=					self.default_image_processor
									__lowercase											=					prepare_img()
									__lowercase											=					image_processor(images=_UpperCAmelCase      ,  return_tensors="""pt""" ).to(_UpperCAmelCase )

									# forward pass
									with torch.no_grad():
															__lowercase											=					model(**_UpperCAmelCase )
									__lowercase											=					outputs.logits

									# verify the logits
									__lowercase											=					torch.Size((1, 1_000) )
									self.assertEqual(logits.shape      ,  _UpperCAmelCase )

									__lowercase											=					torch.tensor([0.3277, -0.1395, 0.0911] ).to(_UpperCAmelCase )

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

									__lowercase											=					[model.config.labelaid[i] for i in ["""remote control, remote""", """tabby, tabby cat"""]]
									self.assertEqual(logits[0].topk(2 ).indices.cpu().tolist()      ,  _UpperCAmelCase )













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 BlipImageProcessor


class 		lowerCAmelCase_				(  unittest.TestCase ):





     def __init__(	self							, _UpperCAmelCase							, _UpperCAmelCase=7							, _UpperCAmelCase=3							, _UpperCAmelCase=18							, _UpperCAmelCase=30							, _UpperCAmelCase=400							, _UpperCAmelCase=True							, _UpperCAmelCase=None							, _UpperCAmelCase=True							, _UpperCAmelCase=False							, _UpperCAmelCase=[0.48145466, 0.4578275, 0.40821073]							, _UpperCAmelCase=[0.26862954, 0.26130258, 0.27577711]							, _UpperCAmelCase=True							, )		->				List[str]:
        lowerCamelCase									=size if size is not None else {"""height""": 20, """width""": 20}
        lowerCamelCase									=parent
        lowerCamelCase									=batch_size
        lowerCamelCase									=num_channels
        lowerCamelCase									=image_size
        lowerCamelCase									=min_resolution
        lowerCamelCase									=max_resolution
        lowerCamelCase									=do_resize
        lowerCamelCase									=size
        lowerCamelCase									=do_normalize
        lowerCamelCase									=image_mean
        lowerCamelCase									=image_std
        lowerCamelCase									=do_pad
        lowerCamelCase									=do_convert_rgb





     def 						lowerCamelCase							(	self  )		->				str:
        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_convert_rgb": self.do_convert_rgb,
            "do_pad": self.do_pad,
        }





     def 						lowerCamelCase							(	self							, _UpperCAmelCase=False							, _UpperCAmelCase=False							, _UpperCAmelCase=False  )		->				Optional[int]:
        assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

        if equal_resolution:
           lowerCamelCase									=[]
           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:
           lowerCamelCase									=[]
           for i in range(self.batch_size  ):
              lowerCamelCase				,       lowerCamelCase									=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
           lowerCamelCase									=[Image.fromarray(np.moveaxis(_UpperCAmelCase							, 0							, -1  )  ) for x in image_inputs]

        if torchify:
           lowerCamelCase									=[torch.from_numpy(_UpperCAmelCase  ) for x in image_inputs]

        return image_inputs




@require_torch
@require_vision
class 		lowerCAmelCase_				(  UpperCamelCase				,     unittest.TestCase ):
     __lowerCamelCase       :    str 	=     BlipImageProcessor if is_vision_available() else None





     def 						lowerCamelCase							(	self  )		->				Dict:
        lowerCamelCase									=BlipImageProcessingTester(self  )





     @property
     def 						lowerCamelCase							(	self  )		->				Optional[int]:
        return self.image_processor_tester.prepare_image_processor_dict()





     def 						lowerCamelCase							(	self  )		->				Union[str, Any]:
        lowerCamelCase									=self.image_processing_class(**self.image_processor_dict  )
        self.assertTrue(hasattr(_UpperCAmelCase							, """do_resize"""  )  )
        self.assertTrue(hasattr(_UpperCAmelCase							, """size"""  )  )
        self.assertTrue(hasattr(_UpperCAmelCase							, """do_normalize"""  )  )
        self.assertTrue(hasattr(_UpperCAmelCase							, """image_mean"""  )  )
        self.assertTrue(hasattr(_UpperCAmelCase							, """image_std"""  )  )
        self.assertTrue(hasattr(_UpperCAmelCase							, """do_convert_rgb"""  )  )





     def 						lowerCamelCase							(	self  )		->				Union[str, Any]:
        pass





     def 						lowerCamelCase							(	self  )		->				int:
        # Initialize image_processor
        lowerCamelCase									=self.image_processing_class(**self.image_processor_dict  )
        # create random PIL images
        lowerCamelCase									=self.image_processor_tester.prepare_inputs(equal_resolution=_UpperCAmelCase  )
        for image in image_inputs:
           self.assertIsInstance(_UpperCAmelCase							, Image.Image  )

        # Test not batched input
        lowerCamelCase									=image_processor(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
        lowerCamelCase									=image_processor(_UpperCAmelCase							, 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  )		->				Union[str, Any]:
        # Initialize image_processor
        lowerCamelCase									=self.image_processing_class(**self.image_processor_dict  )
        # create random numpy tensors
        lowerCamelCase									=self.image_processor_tester.prepare_inputs(equal_resolution=_UpperCAmelCase							, numpify=_UpperCAmelCase  )
        for image in image_inputs:
           self.assertIsInstance(_UpperCAmelCase							, np.ndarray  )

        # Test not batched input
        lowerCamelCase									=image_processor(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
        lowerCamelCase									=image_processor(_UpperCAmelCase							, 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  )		->				Optional[Any]:
        # Initialize image_processor
        lowerCamelCase									=self.image_processing_class(**self.image_processor_dict  )
        # create random PyTorch tensors
        lowerCamelCase									=self.image_processor_tester.prepare_inputs(equal_resolution=_UpperCAmelCase							, torchify=_UpperCAmelCase  )
        for image in image_inputs:
           self.assertIsInstance(_UpperCAmelCase							, torch.Tensor  )

        # Test not batched input
        lowerCamelCase									=image_processor(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
        lowerCamelCase									=image_processor(_UpperCAmelCase							, 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"""],
            )							, )




@require_torch
@require_vision
class 		lowerCAmelCase_				(  UpperCamelCase				,     unittest.TestCase ):
     __lowerCamelCase       :    Any 	=     BlipImageProcessor if is_vision_available() else None





     def 						lowerCamelCase							(	self  )		->				Optional[int]:
        lowerCamelCase									=BlipImageProcessingTester(self							, num_channels=4  )
        lowerCamelCase									=3





     @property
     def 						lowerCamelCase							(	self  )		->				Any:
        return self.image_processor_tester.prepare_image_processor_dict()





     def 						lowerCamelCase							(	self  )		->				List[str]:
        lowerCamelCase									=self.image_processing_class(**self.image_processor_dict  )
        self.assertTrue(hasattr(_UpperCAmelCase							, """do_resize"""  )  )
        self.assertTrue(hasattr(_UpperCAmelCase							, """size"""  )  )
        self.assertTrue(hasattr(_UpperCAmelCase							, """do_normalize"""  )  )
        self.assertTrue(hasattr(_UpperCAmelCase							, """image_mean"""  )  )
        self.assertTrue(hasattr(_UpperCAmelCase							, """image_std"""  )  )
        self.assertTrue(hasattr(_UpperCAmelCase							, """do_convert_rgb"""  )  )





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





     def 						lowerCamelCase							(	self  )		->				List[Any]:
        # Initialize image_processor
        lowerCamelCase									=self.image_processing_class(**self.image_processor_dict  )
        # create random PIL images
        lowerCamelCase									=self.image_processor_tester.prepare_inputs(equal_resolution=_UpperCAmelCase  )
        for image in image_inputs:
           self.assertIsInstance(_UpperCAmelCase							, Image.Image  )

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

        # Test batched
        lowerCamelCase									=image_processor(_UpperCAmelCase							, 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.size["""height"""],
                self.image_processor_tester.size["""width"""],
            )							, )