






import unittest

from transformers import ErnieMConfig, is_torch_available
from transformers.testing_utils import 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 (
					    ErnieMForInformationExtraction,
					    ErnieMForMultipleChoice,
					    ErnieMForQuestionAnswering,
					    ErnieMForSequenceClassification,
					    ErnieMForTokenClassification,
					    ErnieMModel,
					)
					from transformers.models.ernie_m.modeling_ernie_m import ERNIE_M_PRETRAINED_MODEL_ARCHIVE_LIST
class   UpperCamelCase			:







		"""simple docstring"""



		def __init__(	self		:							Tuple    ,_SCREAMING_SNAKE_CASE		:							Tuple    ,_SCREAMING_SNAKE_CASE		:							Tuple=1_3    ,_SCREAMING_SNAKE_CASE		:							Dict=7    ,_SCREAMING_SNAKE_CASE		:							Union[str, Any]=True    ,_SCREAMING_SNAKE_CASE		:							Optional[int]=True    ,_SCREAMING_SNAKE_CASE		:							str=True    ,_SCREAMING_SNAKE_CASE		:							Dict=9_9    ,_SCREAMING_SNAKE_CASE		:							int=3_2    ,_SCREAMING_SNAKE_CASE		:							Tuple=5    ,_SCREAMING_SNAKE_CASE		:							List[Any]=4    ,_SCREAMING_SNAKE_CASE		:							str=3_7    ,_SCREAMING_SNAKE_CASE		:							Tuple="gelu"    ,_SCREAMING_SNAKE_CASE		:							Any=0.1    ,_SCREAMING_SNAKE_CASE		:							str=0.1    ,_SCREAMING_SNAKE_CASE		:							Dict=5_1_2    ,_SCREAMING_SNAKE_CASE		:							str=1_6    ,_SCREAMING_SNAKE_CASE		:							Union[str, Any]=2    ,_SCREAMING_SNAKE_CASE		:							Tuple=0.02    ,_SCREAMING_SNAKE_CASE		:							Optional[int]=3    ,_SCREAMING_SNAKE_CASE		:							Optional[Any]=4    ,_SCREAMING_SNAKE_CASE		:							Optional[Any]=None    ,)     -> List[str]:


						'''simple docstring'''
						A									=   parent
						A									=   batch_size
						A									=   seq_length
						A									=   is_training
						A									=   use_input_mask
						A									=   use_labels
						A									=   vocab_size
						A									=   hidden_size
						A									=   num_hidden_layers
						A									=   num_attention_heads
						A									=   intermediate_size
						A									=   hidden_act
						A									=   hidden_dropout_prob
						A									=   attention_probs_dropout_prob
						A									=   max_position_embeddings
						A									=   type_vocab_size
						A									=   type_sequence_label_size
						A									=   initializer_range
						A									=   num_labels
						A									=   num_choices
						A									=   scope
		def    A(	self		:							str		)     -> int:


						'''simple docstring'''
						A									=   ids_tensor([self.batch_size, self.seq_length]    ,self.vocab_size		)

						A									=   None
						if self.use_input_mask:
										A									=   random_attention_mask([self.batch_size, self.seq_length]		)

						A									=   None
						A									=   None
						A									=   None
						if self.use_labels:
										A									=   ids_tensor([self.batch_size]    ,self.type_sequence_label_size		)
										A									=   ids_tensor([self.batch_size, self.seq_length]    ,self.num_labels		)
										A									=   ids_tensor([self.batch_size]    ,self.num_choices		)

						A									=   self.get_config()

						return config, input_ids, input_mask, sequence_labels, token_labels, choice_labels
		def    A(	self		:							Optional[Any]		)     -> List[str]:


						'''simple docstring'''
						A									=   ids_tensor([self.batch_size, self.seq_length]    ,self.vocab_size		)

						A									=   None
						if self.use_input_mask:
										A									=   random_attention_mask([self.batch_size, self.seq_length]		)
						A									=   self.get_config()

						return config, input_ids, input_mask
		def    A(	self		:							Union[str, Any]		)     -> Optional[int]:


						'''simple docstring'''
						return ErnieMConfig(
						    vocab_size=self.vocab_size    ,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    ,max_position_embeddings=self.max_position_embeddings    ,type_vocab_size=self.type_vocab_size    ,initializer_range=self.initializer_range    ,)
		def    A(	self		:							int    ,_SCREAMING_SNAKE_CASE		:							Dict    ,_SCREAMING_SNAKE_CASE		:							Tuple    ,_SCREAMING_SNAKE_CASE		:							Dict    ,_SCREAMING_SNAKE_CASE		:							Any    ,_SCREAMING_SNAKE_CASE		:							Optional[int]    ,_SCREAMING_SNAKE_CASE		:							Any		)     -> Tuple:


						'''simple docstring'''
						A									=   ErnieMModel(config=_SCREAMING_SNAKE_CASE		)
						model.to(_SCREAMING_SNAKE_CASE		)
						model.eval()
						A									=   model(_SCREAMING_SNAKE_CASE    ,return_dict=_SCREAMING_SNAKE_CASE		)
						self.parent.assertEqual(result.last_hidden_state.shape    ,(self.batch_size, self.seq_length, self.hidden_size)		)
		def    A(	self		:							str    ,_SCREAMING_SNAKE_CASE		:							List[str]    ,_SCREAMING_SNAKE_CASE		:							Tuple    ,_SCREAMING_SNAKE_CASE		:							int    ,_SCREAMING_SNAKE_CASE		:							int    ,_SCREAMING_SNAKE_CASE		:							Optional[Any]    ,_SCREAMING_SNAKE_CASE		:							Union[str, Any]		)     -> Tuple:


						'''simple docstring'''
						A									=   ErnieMForQuestionAnswering(config=_SCREAMING_SNAKE_CASE		)
						model.to(_SCREAMING_SNAKE_CASE		)
						model.eval()
						A									=   model(
						    _SCREAMING_SNAKE_CASE    ,attention_mask=_SCREAMING_SNAKE_CASE    ,start_positions=_SCREAMING_SNAKE_CASE    ,end_positions=_SCREAMING_SNAKE_CASE    ,)
						self.parent.assertEqual(result.start_logits.shape    ,(self.batch_size, self.seq_length)		)
						self.parent.assertEqual(result.end_logits.shape    ,(self.batch_size, self.seq_length)		)
		def    A(	self		:							str    ,_SCREAMING_SNAKE_CASE		:							str    ,_SCREAMING_SNAKE_CASE		:							Any    ,_SCREAMING_SNAKE_CASE		:							Optional[int]    ,_SCREAMING_SNAKE_CASE		:							Any    ,_SCREAMING_SNAKE_CASE		:							Dict    ,_SCREAMING_SNAKE_CASE		:							List[str]		)     -> Optional[Any]:


						'''simple docstring'''
						A									=   ErnieMForInformationExtraction(config=_SCREAMING_SNAKE_CASE		)
						model.to(_SCREAMING_SNAKE_CASE		)
						model.eval()
						A									=   torch.ones_like(_SCREAMING_SNAKE_CASE    ,dtype=torch.floataa		)
						A									=   model(
						    _SCREAMING_SNAKE_CASE    ,attention_mask=_SCREAMING_SNAKE_CASE    ,start_positions=_SCREAMING_SNAKE_CASE    ,end_positions=_SCREAMING_SNAKE_CASE    ,)
						self.parent.assertEqual(result.start_logits.shape    ,(self.batch_size, self.seq_length)		)
						self.parent.assertEqual(result.end_logits.shape    ,(self.batch_size, self.seq_length)		)
		def    A(	self		:							Optional[Any]    ,_SCREAMING_SNAKE_CASE		:							List[str]    ,_SCREAMING_SNAKE_CASE		:							int    ,_SCREAMING_SNAKE_CASE		:							Any    ,_SCREAMING_SNAKE_CASE		:							Optional[int]    ,_SCREAMING_SNAKE_CASE		:							Optional[Any]    ,_SCREAMING_SNAKE_CASE		:							Optional[Any]		)     -> Any:


						'''simple docstring'''
						A									=   self.num_labels
						A									=   ErnieMForSequenceClassification(_SCREAMING_SNAKE_CASE		)
						model.to(_SCREAMING_SNAKE_CASE		)
						model.eval()
						A									=   model(_SCREAMING_SNAKE_CASE    ,attention_mask=_SCREAMING_SNAKE_CASE    ,labels=_SCREAMING_SNAKE_CASE		)
						self.parent.assertEqual(result.logits.shape    ,(self.batch_size, self.num_labels)		)
		def    A(	self		:							Union[str, Any]    ,_SCREAMING_SNAKE_CASE		:							Any    ,_SCREAMING_SNAKE_CASE		:							Union[str, Any]    ,_SCREAMING_SNAKE_CASE		:							List[Any]    ,_SCREAMING_SNAKE_CASE		:							str    ,_SCREAMING_SNAKE_CASE		:							Dict    ,_SCREAMING_SNAKE_CASE		:							Optional[int]		)     -> Optional[int]:


						'''simple docstring'''
						A									=   self.num_labels
						A									=   ErnieMForTokenClassification(config=_SCREAMING_SNAKE_CASE		)
						model.to(_SCREAMING_SNAKE_CASE		)
						model.eval()
						input_ids.to(_SCREAMING_SNAKE_CASE		)
						input_mask.to(_SCREAMING_SNAKE_CASE		)
						token_labels.to(_SCREAMING_SNAKE_CASE		)

						A									=   model(_SCREAMING_SNAKE_CASE    ,attention_mask=_SCREAMING_SNAKE_CASE    ,labels=_SCREAMING_SNAKE_CASE		)

						self.parent.assertEqual(result.logits.shape    ,(self.batch_size, self.seq_length, self.num_labels)		)
		def    A(	self		:							List[Any]    ,_SCREAMING_SNAKE_CASE		:							Tuple    ,_SCREAMING_SNAKE_CASE		:							List[str]    ,_SCREAMING_SNAKE_CASE		:							Union[str, Any]    ,_SCREAMING_SNAKE_CASE		:							Any    ,_SCREAMING_SNAKE_CASE		:							Tuple    ,_SCREAMING_SNAKE_CASE		:							int		)     -> List[Any]:


						'''simple docstring'''
						A									=   self.num_choices
						A									=   ErnieMForMultipleChoice(config=_SCREAMING_SNAKE_CASE		)
						model.to(_SCREAMING_SNAKE_CASE		)
						model.eval()
						A									=   input_ids.unsqueeze(1		).expand(-1    ,self.num_choices    ,-1		).contiguous()
						A									=   input_mask.unsqueeze(1		).expand(-1    ,self.num_choices    ,-1		).contiguous()
						A									=   model(
						    _SCREAMING_SNAKE_CASE    ,attention_mask=_SCREAMING_SNAKE_CASE    ,labels=_SCREAMING_SNAKE_CASE    ,)
						self.parent.assertEqual(result.logits.shape    ,(self.batch_size, self.num_choices)		)







		def    A(	self		:							Tuple		)     -> Dict:


						'''simple docstring'''
						A									=   self.prepare_config_and_inputs()
						(
						    (
						    A
						)			,		(
						    A
						)			,		(
						    A
						)			,		(
						    A
						)			,		(
						    A
						)			,		(
						    A
						)			,		
						)									=   config_and_inputs
						A									=   {'input_ids': input_ids, 'attention_mask': input_mask}
						return config, inputs_dict


@require_torch
class   UpperCamelCase			(					snake_case__      ,							snake_case__      ,							unittest.TestCase			):







		"""simple docstring"""



		snake_case			 = (
		    (
		        ErnieMModel,
		        ErnieMForMultipleChoice,
		        ErnieMForQuestionAnswering,
		        ErnieMForSequenceClassification,
		        ErnieMForTokenClassification,
		    )
		    if is_torch_available()
		    else ()
		)
		snake_case			 = ()
		snake_case			 = (
		    {
		        "feature-extraction": ErnieMModel,
		        "question-answering": ErnieMForQuestionAnswering,
		        "text-classification": ErnieMForSequenceClassification,
		        "token-classification": ErnieMForTokenClassification,
		        "zero-shot": ErnieMForSequenceClassification,
		    }
		    if is_torch_available()
		    else {}
		)
		snake_case			 = False
		def    A(	self		:							int    ,_SCREAMING_SNAKE_CASE		:							Tuple    ,_SCREAMING_SNAKE_CASE		:							str    ,_SCREAMING_SNAKE_CASE		:							Optional[Any]    ,_SCREAMING_SNAKE_CASE		:							str    ,_SCREAMING_SNAKE_CASE		:							Tuple		)     -> Tuple:


						'''simple docstring'''
						if pipeline_test_casse_name == "QAPipelineTests":
										return True

						return False
		def    A(	self		:							Dict		)     -> Optional[int]:


						'''simple docstring'''
						A									=   ErnieMModelTester(self		)
						A									=   ConfigTester(self    ,config_class=_SCREAMING_SNAKE_CASE    ,hidden_size=3_7		)
		def    A(	self		:							str		)     -> List[Any]:


						'''simple docstring'''
						self.config_tester.run_common_tests()
		def    A(	self		:							List[Any]		)     -> List[Any]:


						'''simple docstring'''
						A									=   self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_model(*_SCREAMING_SNAKE_CASE		)
		def    A(	self		:							List[Any]		)     -> Optional[int]:


						'''simple docstring'''
						A									=   self.model_tester.prepare_config_and_inputs()
						for type in ["absolute", "relative_key", "relative_key_query"]:
										A									=   type
										self.model_tester.create_and_check_model(*_SCREAMING_SNAKE_CASE		)
		def    A(	self		:							Dict		)     -> str:


						'''simple docstring'''
						A									=   self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_multiple_choice(*_SCREAMING_SNAKE_CASE		)
		def    A(	self		:							Optional[Any]		)     -> Tuple:


						'''simple docstring'''
						A									=   self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_question_answering(*_SCREAMING_SNAKE_CASE		)
		def    A(	self		:							Tuple		)     -> Dict:


						'''simple docstring'''
						A									=   self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_sequence_classification(*_SCREAMING_SNAKE_CASE		)
		def    A(	self		:							Tuple		)     -> Dict:


						'''simple docstring'''
						A									=   self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_information_extraction(*_SCREAMING_SNAKE_CASE		)
		def    A(	self		:							Dict		)     -> List[Any]:


						'''simple docstring'''
						A									=   self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_token_classification(*_SCREAMING_SNAKE_CASE		)







		@slow
		def    A(	self		:							Union[str, Any]		)     -> Union[str, Any]:


						'''simple docstring'''
						for model_name in ERNIE_M_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
										A									=   ErnieMModel.from_pretrained(_SCREAMING_SNAKE_CASE		)
										self.assertIsNotNone(_SCREAMING_SNAKE_CASE		)


@require_torch
class   UpperCamelCase			(					unittest.TestCase			):







		"""simple docstring"""



		@slow
		def    A(	self		:							Union[str, Any]		)     -> Tuple:


						'''simple docstring'''
						A									=   ErnieMModel.from_pretrained('susnato/ernie-m-base_pytorch'		)
						model.eval()
						A									=   torch.tensor([[0, 1, 2, 3, 4, 5]]		)
						A									=   model(_SCREAMING_SNAKE_CASE		)[0]

						# TODO Replace vocab size
						A									=   7_6_8

						A									=   torch.Size((1, 6, hidden_size)		)
						self.assertEqual(output.shape    ,_SCREAMING_SNAKE_CASE		)

						A									=   torch.tensor(
						    [[[-0.0012, 0.1245, -0.0214], [-0.0742, 0.0244, -0.0771], [-0.0333, 0.1164, -0.1554]]]		)

						self.assertTrue(torch.allclose(output[:, :3, :3]    ,_SCREAMING_SNAKE_CASE    ,atol=1E-3		)		)













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		:							int    ,_SCREAMING_SNAKE_CASE		:							Any    ,_SCREAMING_SNAKE_CASE		:							Optional[int]=7    ,_SCREAMING_SNAKE_CASE		:							List[Any]=3    ,_SCREAMING_SNAKE_CASE		:							int=1_8    ,_SCREAMING_SNAKE_CASE		:							Tuple=3_0    ,_SCREAMING_SNAKE_CASE		:							Optional[Any]=4_0_0    ,_SCREAMING_SNAKE_CASE		:							Dict=True    ,_SCREAMING_SNAKE_CASE		:							int=None    ,_SCREAMING_SNAKE_CASE		:							Tuple=True    ,_SCREAMING_SNAKE_CASE		:							Any=None    ,_SCREAMING_SNAKE_CASE		:							Dict=True    ,_SCREAMING_SNAKE_CASE		:							List[str]=[0.48145466, 0.4578275, 0.40821073]    ,_SCREAMING_SNAKE_CASE		:							int=[0.26862954, 0.26130258, 0.27577711]    ,_SCREAMING_SNAKE_CASE		:							Union[str, Any]=True    ,)     -> List[str]:


						'''simple docstring'''
						A									=   size if size is not None else {'shortest_edge': 2_0}
						A									=   crop_size if crop_size is not None else {'height': 1_8, 'width': 1_8}
						A									=   parent
						A									=   batch_size
						A									=   num_channels
						A									=   image_size
						A									=   min_resolution
						A									=   max_resolution
						A									=   do_resize
						A									=   size
						A									=   do_center_crop
						A									=   crop_size
						A									=   do_normalize
						A									=   image_mean
						A									=   image_std
						A									=   do_convert_rgb
		def    A(	self		:							List[str]		)     -> Optional[int]:


						'''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    A(	self		:							Optional[int]    ,_SCREAMING_SNAKE_CASE		:							str=False    ,_SCREAMING_SNAKE_CASE		:							List[str]=False    ,_SCREAMING_SNAKE_CASE		:							Optional[Any]=False		)     -> str:


						'''simple docstring'''
						assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

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

						if torchify:
										A									=   [torch.from_numpy(_SCREAMING_SNAKE_CASE		) for x in image_inputs]

						return image_inputs


@require_torch
@require_vision
class   UpperCamelCase			(					snake_case__      ,							unittest.TestCase			):







		"""simple docstring"""



		snake_case			 = CLIPImageProcessor if is_vision_available() else None
		def    A(	self		:							Optional[Any]		)     -> Union[str, Any]:


						'''simple docstring'''
						A									=   CLIPImageProcessingTester(self		)
		@property
		def    A(	self		:							Optional[int]		)     -> Any:


						'''simple docstring'''
						return self.image_processor_tester.prepare_image_processor_dict()
		def    A(	self		:							Optional[int]		)     -> Tuple:


						'''simple docstring'''
						A									=   self.image_processing_class(**self.image_processor_dict		)
						self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE    ,'do_resize'		)		)
						self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE    ,'size'		)		)
						self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE    ,'do_center_crop'		)		)
						self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE    ,'center_crop'		)		)
						self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE    ,'do_normalize'		)		)
						self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE    ,'image_mean'		)		)
						self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE    ,'image_std'		)		)
						self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE    ,'do_convert_rgb'		)		)
		def    A(	self		:							Optional[Any]		)     -> int:


						'''simple docstring'''
						A									=   self.image_processing_class.from_dict(self.image_processor_dict		)
						self.assertEqual(image_processor.size    ,{'shortest_edge': 2_0}		)
						self.assertEqual(image_processor.crop_size    ,{'height': 1_8, 'width': 1_8}		)

						A									=   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    A(	self		:							Any		)     -> Union[str, Any]:


						'''simple docstring'''
						pass
		def    A(	self		:							Tuple		)     -> Optional[int]:


						'''simple docstring'''
						# Initialize image_processing
						A									=   self.image_processing_class(**self.image_processor_dict		)
						# create random PIL images
						A									=   self.image_processor_tester.prepare_inputs(equal_resolution=_SCREAMING_SNAKE_CASE		)
						for image in image_inputs:
										self.assertIsInstance(_SCREAMING_SNAKE_CASE    ,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.crop_size['height'],
						        self.image_processor_tester.crop_size['width'],
						    )    ,)

						# Test batched
						A									=   image_processing(_SCREAMING_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    A(	self		:							int		)     -> Tuple:


						'''simple docstring'''
						# Initialize image_processing
						A									=   self.image_processing_class(**self.image_processor_dict		)
						# create random numpy tensors
						A									=   self.image_processor_tester.prepare_inputs(equal_resolution=_SCREAMING_SNAKE_CASE    ,numpify=_SCREAMING_SNAKE_CASE		)
						for image in image_inputs:
										self.assertIsInstance(_SCREAMING_SNAKE_CASE    ,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.crop_size['height'],
						        self.image_processor_tester.crop_size['width'],
						    )    ,)

						# Test batched
						A									=   image_processing(_SCREAMING_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    A(	self		:							str		)     -> str:


						'''simple docstring'''
						# Initialize image_processing
						A									=   self.image_processing_class(**self.image_processor_dict		)
						# create random PyTorch tensors
						A									=   self.image_processor_tester.prepare_inputs(equal_resolution=_SCREAMING_SNAKE_CASE    ,torchify=_SCREAMING_SNAKE_CASE		)
						for image in image_inputs:
										self.assertIsInstance(_SCREAMING_SNAKE_CASE    ,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.crop_size['height'],
						        self.image_processor_tester.crop_size['width'],
						    )    ,)

						# Test batched
						A									=   image_processing(_SCREAMING_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			(					snake_case__      ,							unittest.TestCase			):







		"""simple docstring"""



		snake_case			 = CLIPImageProcessor if is_vision_available() else None
		def    A(	self		:							Tuple		)     -> Union[str, Any]:


						'''simple docstring'''
						A									=   CLIPImageProcessingTester(self    ,num_channels=4		)
						A									=   3
		@property
		def    A(	self		:							str		)     -> Dict:


						'''simple docstring'''
						return self.image_processor_tester.prepare_image_processor_dict()
		def    A(	self		:							Any		)     -> int:


						'''simple docstring'''
						A									=   self.image_processing_class(**self.image_processor_dict		)
						self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE    ,'do_resize'		)		)
						self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE    ,'size'		)		)
						self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE    ,'do_center_crop'		)		)
						self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE    ,'center_crop'		)		)
						self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE    ,'do_normalize'		)		)
						self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE    ,'image_mean'		)		)
						self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE    ,'image_std'		)		)
						self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE    ,'do_convert_rgb'		)		)
		def    A(	self		:							Any		)     -> str:


						'''simple docstring'''
						pass







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


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

						# Test not batched input
						A									=   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
						A									=   image_processing(_SCREAMING_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'],
						    )    ,)





