

"""simple docstring"""




import unittest

from transformers import EsmConfig, is_torch_available
from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
     import torch

     from transformers import EsmForMaskedLM, EsmForSequenceClassification, EsmForTokenClassification, EsmModel
     from transformers.models.esm.modeling_esm import (
         ESM_PRETRAINED_MODEL_ARCHIVE_LIST,
         EsmEmbeddings,
         create_position_ids_from_input_ids,
     )





class  __UpperCAmelCase					:



   def __init__(							self							:					Optional[Any],		__A							:					int,		__A							:					Dict=1_3,		__A							:					int=7,		__A							:					Dict=False,		__A							:					List[str]=True,		__A							:					int=False,		__A							:					int=True,		__A							:					Union[str, Any]=3_3,		__A							:					int=3_2,		__A							:					Dict=5,		__A							:					Union[str, Any]=4,		__A							:					Tuple=3_7,		__A							:					List[str]="gelu",		__A							:					Tuple=0.1,		__A							:					Union[str, Any]=0.1,		__A							:					Union[str, Any]=5_1_2,		__A							:					Union[str, Any]=1_6,		__A							:					str=2,		__A							:					Dict=0.0_2,		__A							:					str=3,		__A							:					Optional[Any]=4,		__A							:					Any=None,		):
     UpperCAmelCase	:							Tuple						=			parent
     UpperCAmelCase	:							List[str]						=			batch_size
     UpperCAmelCase	:							str						=			seq_length
     UpperCAmelCase	:							Tuple						=			is_training
     UpperCAmelCase	:							Optional[Any]						=			use_input_mask
     UpperCAmelCase	:							Dict						=			use_token_type_ids
     UpperCAmelCase	:							str						=			use_labels
     UpperCAmelCase	:							Optional[Any]						=			vocab_size
     UpperCAmelCase	:							Dict						=			hidden_size
     UpperCAmelCase	:							Tuple						=			num_hidden_layers
     UpperCAmelCase	:							Optional[Any]						=			num_attention_heads
     UpperCAmelCase	:							List[Any]						=			intermediate_size
     UpperCAmelCase	:							Optional[int]						=			hidden_act
     UpperCAmelCase	:							Optional[Any]						=			hidden_dropout_prob
     UpperCAmelCase	:							str						=			attention_probs_dropout_prob
     UpperCAmelCase	:							Any						=			max_position_embeddings
     UpperCAmelCase	:							Tuple						=			type_vocab_size
     UpperCAmelCase	:							List[Any]						=			type_sequence_label_size
     UpperCAmelCase	:							Any						=			initializer_range
     UpperCAmelCase	:							int						=			num_labels
     UpperCAmelCase	:							Optional[int]						=			num_choices
     UpperCAmelCase	:							Optional[int]						=			scope



   def 	__magic_name__   (							self							:					Tuple						):
     UpperCAmelCase	:							Optional[int]						=			ids_tensor([self.batch_size, self.seq_length],		self.vocab_size						)

     UpperCAmelCase	:							Dict						=			None
     if self.use_input_mask:
       UpperCAmelCase	:							str						=			random_attention_mask([self.batch_size, self.seq_length]						)

     UpperCAmelCase	:							Optional[int]						=			None
     UpperCAmelCase	:							List[Any]						=			None
     UpperCAmelCase	:							Dict						=			None
     if self.use_labels:
       UpperCAmelCase	:							Any						=			ids_tensor([self.batch_size],		self.type_sequence_label_size						)
       UpperCAmelCase	:							int						=			ids_tensor([self.batch_size, self.seq_length],		self.num_labels						)
       UpperCAmelCase	:							int						=			ids_tensor([self.batch_size],		self.num_choices						)

     UpperCAmelCase	:							Tuple						=			self.get_config()

     return config, input_ids, input_mask, sequence_labels, token_labels, choice_labels



   def 	__magic_name__   (							self							:					Any						):
     return EsmConfig(
         vocab_size=self.vocab_size,		hidden_size=self.hidden_size,		pad_token_id=1,		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,		max_position_embeddings=self.max_position_embeddings,		type_vocab_size=self.type_vocab_size,		initializer_range=self.initializer_range,		)



   def 	__magic_name__   (							self							:					int,		__A							:					Tuple,		__A							:					Union[str, Any],		__A							:					List[Any],		__A							:					Optional[Any],		__A							:					List[str],		__A							:					Union[str, Any]						):
     UpperCAmelCase	:							Dict						=			EsmModel(config=_snake_case						)
     model.to(_snake_case						)
     model.eval()
     UpperCAmelCase	:							Union[str, Any]						=			model(_snake_case,		attention_mask=_snake_case						)
     UpperCAmelCase	:							Tuple						=			model(_snake_case						)
     UpperCAmelCase	:							List[str]						=			model(_snake_case						)

     self.parent.assertEqual(result.last_hidden_state.shape,		(self.batch_size, self.seq_length, self.hidden_size)						)
     self.parent.assertEqual(result.pooler_output.shape,		(self.batch_size, self.hidden_size)						)



   def 	__magic_name__   (							self							:					List[Any],		__A							:					Optional[int],		__A							:					List[Any],		__A							:					str,		__A							:					Any,		__A							:					Optional[Any],		__A							:					Optional[Any]						):
     UpperCAmelCase	:							Optional[Any]						=			EsmForMaskedLM(config=_snake_case						)
     model.to(_snake_case						)
     model.eval()
     UpperCAmelCase	:							Tuple						=			model(_snake_case,		attention_mask=_snake_case,		labels=_snake_case						)
     self.parent.assertEqual(result.logits.shape,		(self.batch_size, self.seq_length, self.vocab_size)						)



   def 	__magic_name__   (							self							:					Union[str, Any],		__A							:					str,		__A							:					Any,		__A							:					List[Any],		__A							:					str,		__A							:					List[Any],		__A							:					Optional[int]						):
     UpperCAmelCase	:							Any						=			self.num_labels
     UpperCAmelCase	:							Optional[int]						=			EsmForTokenClassification(config=_snake_case						)
     model.to(_snake_case						)
     model.eval()
     UpperCAmelCase	:							Tuple						=			model(_snake_case,		attention_mask=_snake_case,		labels=_snake_case						)
     self.parent.assertEqual(result.logits.shape,		(self.batch_size, self.seq_length, self.num_labels)						)





   def 	__magic_name__   (							self							:					str						):
     UpperCAmelCase	:							str						=			self.prepare_config_and_inputs()
     (
         (
         UpperCAmelCase	
     )			,						(
         UpperCAmelCase	
     )			,						(
         UpperCAmelCase	
     )			,						(
         UpperCAmelCase	
     )			,						(
         UpperCAmelCase	
     )			,						(
         UpperCAmelCase	
     )			,							
     )	:							Dict						=			config_and_inputs
     UpperCAmelCase	:							Optional[int]						=			{'''input_ids''': input_ids, '''attention_mask''': input_mask}
     return config, inputs_dict






@require_torch
class  __UpperCAmelCase					(	lowerCamelCase__      ,  lowerCamelCase__      ,  unittest.TestCase						):
   UpperCamelCase       					=					False

   UpperCamelCase       					=					(
       (
           EsmForMaskedLM,
           EsmModel,
           EsmForSequenceClassification,
           EsmForTokenClassification,
       )
       if is_torch_available()
       else ()
   )
   UpperCamelCase       					=					()
   UpperCamelCase       					=					(
       {
           '''feature-extraction''': EsmModel,
           '''fill-mask''': EsmForMaskedLM,
           '''text-classification''': EsmForSequenceClassification,
           '''token-classification''': EsmForTokenClassification,
           '''zero-shot''': EsmForSequenceClassification,
       }
       if is_torch_available()
       else {}
   )
   UpperCamelCase       					=					True



   def 	__magic_name__   (							self							:					Union[str, Any]						):
     UpperCAmelCase	:							Optional[int]						=			EsmModelTester(self						)
     UpperCAmelCase	:							Any						=			ConfigTester(self,		config_class=_snake_case,		hidden_size=3_7						)



   def 	__magic_name__   (							self							:					int						):
     self.config_tester.run_common_tests()



   def 	__magic_name__   (							self							:					Any						):
     UpperCAmelCase	:							Tuple						=			self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_model(*_snake_case						)



   def 	__magic_name__   (							self							:					List[str]						):
     UpperCAmelCase	:							Optional[int]						=			self.model_tester.prepare_config_and_inputs()
     for type in ["absolute", "relative_key", "relative_key_query"]:
       UpperCAmelCase	:							Tuple						=			type
       self.model_tester.create_and_check_model(*_snake_case						)



   def 	__magic_name__   (							self							:					List[Any]						):
     UpperCAmelCase	:							Any						=			self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_masked_lm(*_snake_case						)



   def 	__magic_name__   (							self							:					Any						):
     UpperCAmelCase	:							Tuple						=			self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_token_classification(*_snake_case						)



   @slow
   def 	__magic_name__   (							self							:					str						):


     for model_name in ESM_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
       UpperCAmelCase	:							List[Any]						=			EsmModel.from_pretrained(_snake_case						)
       self.assertIsNotNone(_snake_case						)



   def 	__magic_name__   (							self							:					List[str]						):
     UpperCAmelCase	:							Tuple						=			self.model_tester.prepare_config_and_inputs()[0]
     UpperCAmelCase	:							List[str]						=			EsmEmbeddings(config=_snake_case						)

     UpperCAmelCase	:							Tuple						=			torch.as_tensor([[1_2, 3_1, 1_3, model.padding_idx]]						)
     UpperCAmelCase	:							List[Any]						=			torch.as_tensor(
         [
             [
                 0 + model.padding_idx + 1,
                 1 + model.padding_idx + 1,
                 2 + model.padding_idx + 1,
                 model.padding_idx,
             ]
         ]						)
     UpperCAmelCase	:							List[Any]						=			create_position_ids_from_input_ids(_snake_case,		model.padding_idx						)
     self.assertEqual(position_ids.shape,		expected_positions.shape						)
     self.assertTrue(torch.all(torch.eq(_snake_case,		_snake_case						)						)						)



   def 	__magic_name__   (							self							:					Optional[int]						):
     UpperCAmelCase	:							List[Any]						=			self.model_tester.prepare_config_and_inputs()[0]
     UpperCAmelCase	:							Dict						=			EsmEmbeddings(config=_snake_case						)

     UpperCAmelCase	:							Tuple						=			torch.empty(2,		4,		3_0						)
     UpperCAmelCase	:							Optional[Any]						=			[
         0 + embeddings.padding_idx + 1,
         1 + embeddings.padding_idx + 1,
         2 + embeddings.padding_idx + 1,
         3 + embeddings.padding_idx + 1,
     ]
     UpperCAmelCase	:							str						=			torch.as_tensor([expected_single_positions, expected_single_positions]						)
     UpperCAmelCase	:							Union[str, Any]						=			embeddings.create_position_ids_from_inputs_embeds(_snake_case						)
     self.assertEqual(position_ids.shape,		expected_positions.shape						)
     self.assertTrue(torch.all(torch.eq(_snake_case,		_snake_case						)						)						)



   @unittest.skip('''Esm does not support embedding resizing'''						)
   def 	__magic_name__   (							self							:					List[str]						):
     pass



   @unittest.skip('''Esm does not support embedding resizing'''						)
   def 	__magic_name__   (							self							:					Optional[int]						):
     pass





   @unittest.skip('''Will be fixed soon by reducing the size of the model used for common tests.'''						)
   def 	__magic_name__   (							self							:					Any						):
     pass






@require_torch
class  __UpperCAmelCase					(	lowerCamelCase__						):



   @slow
   def 	__magic_name__   (							self							:					Dict						):


     with torch.no_grad():
       UpperCAmelCase	:							Dict						=			EsmForMaskedLM.from_pretrained('''facebook/esm2_t6_8M_UR50D'''						)
       model.eval()
       UpperCAmelCase	:							Tuple						=			torch.tensor([[0, 1, 2, 3, 4, 5]]						)
       UpperCAmelCase	:							str						=			model(_snake_case						)[0]

       UpperCAmelCase	:							Tuple						=			3_3

       UpperCAmelCase	:							List[Any]						=			torch.Size((1, 6, vocab_size)						)
       self.assertEqual(output.shape,		_snake_case						)

       UpperCAmelCase	:							List[Any]						=			torch.tensor(
           [[[8.9_2_1_5, -1_0.5_8_9_8, -6.4_6_7_1], [-6.3_9_6_7, -1_3.9_1_1_4, -1.1_2_1_2], [-7.7_8_1_2, -1_3.9_5_1_6, -3.7_4_0_6]]]						)
       self.assertTrue(torch.allclose(output[:, :3, :3],		_snake_case,		atol=1E-4						)						)





   @slow
   def 	__magic_name__   (							self							:					Optional[Any]						):


     with torch.no_grad():
       UpperCAmelCase	:							Any						=			EsmModel.from_pretrained('''facebook/esm2_t6_8M_UR50D'''						)
       model.eval()

       UpperCAmelCase	:							int						=			torch.tensor([[0, 6, 4, 1_3, 5, 4, 1_6, 1_2, 1_1, 7, 2]]						)
       UpperCAmelCase	:							Optional[Any]						=			model(_snake_case						)[0]
       # compare the actual values for a slice.
       UpperCAmelCase	:							int						=			torch.tensor(
           [[[0.1_4_4_4, 0.5_4_1_3, 0.3_2_4_8], [0.3_0_3_4, 0.0_0_5_3, 0.3_1_0_8], [0.3_2_2_8, -0.2_4_9_9, 0.3_4_1_5]]]						)
       self.assertTrue(torch.allclose(output[:, :3, :3],		_snake_case,		atol=1E-4						)						)








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 ChineseCLIPImageProcessor





class  __UpperCAmelCase					(	unittest.TestCase						):



   def __init__(							self							:					List[Any],		__A							:					str,		__A							:					List[str]=7,		__A							:					List[str]=3,		__A							:					Optional[int]=1_8,		__A							:					List[Any]=3_0,		__A							:					Tuple=4_0_0,		__A							:					Tuple=True,		__A							:					List[Any]=None,		__A							:					str=True,		__A							:					int=None,		__A							:					Optional[Any]=True,		__A							:					List[Any]=[0.4_8_1_4_5_4_6_6, 0.4_5_7_8_2_7_5, 0.4_0_8_2_1_0_7_3],		__A							:					List[str]=[0.2_6_8_6_2_9_5_4, 0.2_6_1_3_0_2_5_8, 0.2_7_5_7_7_7_1_1],		__A							:					Tuple=True,		):
     UpperCAmelCase	:							int						=			size if size is not None else {'''height''': 2_2_4, '''width''': 2_2_4}
     UpperCAmelCase	:							Optional[Any]						=			crop_size if crop_size is not None else {'''height''': 1_8, '''width''': 1_8}
     UpperCAmelCase	:							int						=			parent
     UpperCAmelCase	:							Union[str, Any]						=			batch_size
     UpperCAmelCase	:							List[Any]						=			num_channels
     UpperCAmelCase	:							Dict						=			image_size
     UpperCAmelCase	:							List[str]						=			min_resolution
     UpperCAmelCase	:							Optional[Any]						=			max_resolution
     UpperCAmelCase	:							Union[str, Any]						=			do_resize
     UpperCAmelCase	:							Dict						=			size
     UpperCAmelCase	:							Any						=			do_center_crop
     UpperCAmelCase	:							Union[str, Any]						=			crop_size
     UpperCAmelCase	:							List[str]						=			do_normalize
     UpperCAmelCase	:							Optional[Any]						=			image_mean
     UpperCAmelCase	:							Optional[Any]						=			image_std
     UpperCAmelCase	:							List[Any]						=			do_convert_rgb



   def 	__magic_name__   (							self							:					int						):
     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 	__magic_name__   (							self							:					Optional[Any],		__A							:					Any=False,		__A							:					str=False,		__A							:					List[Any]=False						):
     assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

     if equal_resolution:
       UpperCAmelCase	:							Dict						=			[]
       for i in range(self.batch_size						):
         image_inputs.append(
             np.random.randint(
                 2_5_5,		size=(self.num_channels, self.max_resolution, self.max_resolution),		dtype=np.uinta						)						)
     else:
       UpperCAmelCase	:							Tuple						=			[]
       for i in range(self.batch_size						):
         UpperCAmelCase			,						UpperCAmelCase	:							Tuple						=			np.random.choice(np.arange(self.min_resolution,		self.max_resolution						),		2						)
         image_inputs.append(np.random.randint(2_5_5,		size=(self.num_channels, width, height),		dtype=np.uinta						)						)

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

     if torchify:
       UpperCAmelCase	:							str						=			[torch.from_numpy(__A						) for x in image_inputs]

     return image_inputs






@require_torch
@require_vision
class  __UpperCAmelCase					(	lowerCamelCase__      ,  unittest.TestCase						):
   UpperCamelCase       					=					ChineseCLIPImageProcessor if is_vision_available() else None



   def 	__magic_name__   (							self							:					Dict						):
     UpperCAmelCase	:							Optional[Any]						=			ChineseCLIPImageProcessingTester(self,		do_center_crop=__A						)



   @property
   def 	__magic_name__   (							self							:					Tuple						):
     return self.image_processor_tester.prepare_image_processor_dict()



   def 	__magic_name__   (							self							:					Any						):
     UpperCAmelCase	:							List[Any]						=			self.image_processing_class(**self.image_processor_dict						)
     self.assertTrue(hasattr(__A,		'''do_resize'''						)						)
     self.assertTrue(hasattr(__A,		'''size'''						)						)
     self.assertTrue(hasattr(__A,		'''do_center_crop'''						)						)
     self.assertTrue(hasattr(__A,		'''center_crop'''						)						)
     self.assertTrue(hasattr(__A,		'''do_normalize'''						)						)
     self.assertTrue(hasattr(__A,		'''image_mean'''						)						)
     self.assertTrue(hasattr(__A,		'''image_std'''						)						)
     self.assertTrue(hasattr(__A,		'''do_convert_rgb'''						)						)



   def 	__magic_name__   (							self							:					Optional[Any]						):
     UpperCAmelCase	:							Union[str, Any]						=			self.image_processing_class.from_dict(self.image_processor_dict						)
     self.assertEqual(image_processor.size,		{'''height''': 2_2_4, '''width''': 2_2_4}						)
     self.assertEqual(image_processor.crop_size,		{'''height''': 1_8, '''width''': 1_8}						)

     UpperCAmelCase	:							int						=			self.image_processing_class.from_dict(self.image_processor_dict,		size=4_2,		crop_size=8_4						)
     self.assertEqual(image_processor.size,		{'''shortest_edge''': 4_2}						)
     self.assertEqual(image_processor.crop_size,		{'''height''': 8_4, '''width''': 8_4}						)



   def 	__magic_name__   (							self							:					Union[str, Any]						):
     pass



   def 	__magic_name__   (							self							:					Tuple						):
     # Initialize image_processing
     UpperCAmelCase	:							Dict						=			self.image_processing_class(**self.image_processor_dict						)
     # create random PIL images
     UpperCAmelCase	:							Optional[int]						=			self.image_processor_tester.prepare_inputs(equal_resolution=__A						)
     for image in image_inputs:
       self.assertIsInstance(__A,		Image.Image						)

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

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

     # Test not batched input
     UpperCAmelCase	:							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
     UpperCAmelCase	:							List[str]						=			image_processing(__A,		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					(	lowerCamelCase__      ,  unittest.TestCase						):
   UpperCamelCase       					=					ChineseCLIPImageProcessor if is_vision_available() else None



   def 	__magic_name__   (							self							:					Optional[Any]						):
     UpperCAmelCase	:							str						=			ChineseCLIPImageProcessingTester(self,		num_channels=4,		do_center_crop=__A						)
     UpperCAmelCase	:							Dict						=			3



   @property
   def 	__magic_name__   (							self							:					List[Any]						):
     return self.image_processor_tester.prepare_image_processor_dict()



   def 	__magic_name__   (							self							:					Dict						):
     UpperCAmelCase	:							List[Any]						=			self.image_processing_class(**self.image_processor_dict						)
     self.assertTrue(hasattr(__A,		'''do_resize'''						)						)
     self.assertTrue(hasattr(__A,		'''size'''						)						)
     self.assertTrue(hasattr(__A,		'''do_center_crop'''						)						)
     self.assertTrue(hasattr(__A,		'''center_crop'''						)						)
     self.assertTrue(hasattr(__A,		'''do_normalize'''						)						)
     self.assertTrue(hasattr(__A,		'''image_mean'''						)						)
     self.assertTrue(hasattr(__A,		'''image_std'''						)						)
     self.assertTrue(hasattr(__A,		'''do_convert_rgb'''						)						)



   def 	__magic_name__   (							self							:					List[Any]						):
     pass





   def 	__magic_name__   (							self							:					Tuple						):
     # Initialize image_processing
     UpperCAmelCase	:							Optional[Any]						=			self.image_processing_class(**self.image_processor_dict						)
     # create random PIL images
     UpperCAmelCase	:							Dict						=			self.image_processor_tester.prepare_inputs(equal_resolution=__A						)
     for image in image_inputs:
       self.assertIsInstance(__A,		Image.Image						)

     # Test not batched input
     UpperCAmelCase	:							Tuple						=			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
     UpperCAmelCase	:							Tuple						=			image_processing(__A,		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'''],
         ),		)





