from __future__ import annotations

import unittest

from transformers import MobileBertConfig, is_tf_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
							import tensorflow as tf

							from transformers import (
							    TF_MODEL_FOR_PRETRAINING_MAPPING,
							    TFMobileBertForMaskedLM,
							    TFMobileBertForMultipleChoice,
							    TFMobileBertForNextSentencePrediction,
							    TFMobileBertForPreTraining,
							    TFMobileBertForQuestionAnswering,
							    TFMobileBertForSequenceClassification,
							    TFMobileBertForTokenClassification,
							    TFMobileBertModel,
							)


@require_tf
class 						lowercase    (     a				,       a				,       unittest.TestCase     ):
							lowercase__						:       Optional[int]								=							(
							    (
							        TFMobileBertModel,
							        TFMobileBertForMaskedLM,
							        TFMobileBertForNextSentencePrediction,
							        TFMobileBertForPreTraining,
							        TFMobileBertForQuestionAnswering,
							        TFMobileBertForSequenceClassification,
							        TFMobileBertForTokenClassification,
							        TFMobileBertForMultipleChoice,
							    )
							    if is_tf_available()
							    else ()
							)
							lowercase__						:       int								=							(
							    {
							        """feature-extraction""": TFMobileBertModel,
							        """fill-mask""": TFMobileBertForMaskedLM,
							        """question-answering""": TFMobileBertForQuestionAnswering,
							        """text-classification""": TFMobileBertForSequenceClassification,
							        """token-classification""": TFMobileBertForTokenClassification,
							        """zero-shot""": TFMobileBertForSequenceClassification,
							    }
							    if is_tf_available()
							    else {}
							)
							lowercase__						:       Any								=							False
							lowercase__						:       Any								=							False




							def 	__snake_case(						self   :					Dict	,							_UpperCamelCase   :					Any	,							_UpperCamelCase   :					Dict	,							_UpperCamelCase   :					Optional[int]=False      )					->				Any:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       super()._prepare_for_class(_UpperCamelCase	,							_UpperCamelCase	,							return_labels=_UpperCamelCase      )

												if return_labels:
																	if model_class in get_values(_UpperCamelCase      ):
																						SCREAMING_SNAKE_CASE    			=       tf.zeros(self.model_tester.batch_size	,							dtype=tf.intaa      )

												return inputs_dict


							class 						lowercase    (     a     ):




														def __init__(						self   :					str	,							_UpperCamelCase   :					Any	,							_UpperCamelCase   :					Dict=13	,							_UpperCamelCase   :					Optional[Any]=7	,							_UpperCamelCase   :					List[Any]=True	,							_UpperCamelCase   :					Optional[int]=True	,							_UpperCamelCase   :					int=True	,							_UpperCamelCase   :					int=True	,							_UpperCamelCase   :					Union[str, Any]=99	,							_UpperCamelCase   :					Tuple=32	,							_UpperCamelCase   :					Any=32	,							_UpperCamelCase   :					Dict=2	,							_UpperCamelCase   :					Optional[int]=4	,							_UpperCamelCase   :					int=37	,							_UpperCamelCase   :					Union[str, Any]="gelu"	,							_UpperCamelCase   :					Tuple=0.1	,							_UpperCamelCase   :					Optional[int]=0.1	,							_UpperCamelCase   :					Optional[int]=512	,							_UpperCamelCase   :					Any=16	,							_UpperCamelCase   :					Union[str, Any]=2	,							_UpperCamelCase   :					Tuple=0.0_2	,							_UpperCamelCase   :					List[Any]=3	,							_UpperCamelCase   :					Optional[int]=4	,							_UpperCamelCase   :					str=None	,							)					->				Any:



																			'''simple docstring'''

																			SCREAMING_SNAKE_CASE    			=       parent
																			SCREAMING_SNAKE_CASE    			=       batch_size
																			SCREAMING_SNAKE_CASE    			=       seq_length
																			SCREAMING_SNAKE_CASE    			=       is_training
																			SCREAMING_SNAKE_CASE    			=       use_input_mask
																			SCREAMING_SNAKE_CASE    			=       use_token_type_ids
																			SCREAMING_SNAKE_CASE    			=       use_labels
																			SCREAMING_SNAKE_CASE    			=       vocab_size
																			SCREAMING_SNAKE_CASE    			=       hidden_size
																			SCREAMING_SNAKE_CASE    			=       num_hidden_layers
																			SCREAMING_SNAKE_CASE    			=       num_attention_heads
																			SCREAMING_SNAKE_CASE    			=       intermediate_size
																			SCREAMING_SNAKE_CASE    			=       hidden_act
																			SCREAMING_SNAKE_CASE    			=       hidden_dropout_prob
																			SCREAMING_SNAKE_CASE    			=       attention_probs_dropout_prob
																			SCREAMING_SNAKE_CASE    			=       max_position_embeddings
																			SCREAMING_SNAKE_CASE    			=       type_vocab_size
																			SCREAMING_SNAKE_CASE    			=       type_sequence_label_size
																			SCREAMING_SNAKE_CASE    			=       initializer_range
																			SCREAMING_SNAKE_CASE    			=       num_labels
																			SCREAMING_SNAKE_CASE    			=       num_choices
																			SCREAMING_SNAKE_CASE    			=       scope
																			SCREAMING_SNAKE_CASE    			=       embedding_size




														def 	__snake_case(						self   :					int      )					->				Union[str, Any]:



																			'''simple docstring'''

																			SCREAMING_SNAKE_CASE    			=       ids_tensor([self.batch_size, self.seq_length]	,							self.vocab_size      )

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

																			SCREAMING_SNAKE_CASE    			=       None
																			if self.use_token_type_ids:
																								SCREAMING_SNAKE_CASE    			=       ids_tensor([self.batch_size, self.seq_length]	,							self.type_vocab_size      )

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

																			SCREAMING_SNAKE_CASE    			=       MobileBertConfig(
																			    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	,							embedding_size=self.embedding_size	,							)

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




														def 	__snake_case(						self   :					Any	,							_UpperCamelCase   :					Dict	,							_UpperCamelCase   :					int	,							_UpperCamelCase   :					Dict	,							_UpperCamelCase   :					int	,							_UpperCamelCase   :					Any	,							_UpperCamelCase   :					Dict	,							_UpperCamelCase   :					Any      )					->				str:



																			'''simple docstring'''

																			SCREAMING_SNAKE_CASE    			=       TFMobileBertModel(config=_UpperCamelCase      )
																			SCREAMING_SNAKE_CASE    			=       {"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
																			SCREAMING_SNAKE_CASE    			=       model(_UpperCamelCase      )

																			SCREAMING_SNAKE_CASE    			=       [input_ids, input_mask]
																			SCREAMING_SNAKE_CASE    			=       model(_UpperCamelCase      )

																			SCREAMING_SNAKE_CASE    			=       model(_UpperCamelCase      )

																			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 	__snake_case(						self   :					Tuple	,							_UpperCamelCase   :					Tuple	,							_UpperCamelCase   :					Tuple	,							_UpperCamelCase   :					Optional[int]	,							_UpperCamelCase   :					List[str]	,							_UpperCamelCase   :					Dict	,							_UpperCamelCase   :					int	,							_UpperCamelCase   :					Union[str, Any]      )					->				Dict:



																			'''simple docstring'''

																			SCREAMING_SNAKE_CASE    			=       TFMobileBertForMaskedLM(config=_UpperCamelCase      )
																			SCREAMING_SNAKE_CASE    			=       {"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
																			SCREAMING_SNAKE_CASE    			=       model(_UpperCamelCase      )
																			self.parent.assertEqual(result.logits.shape	,							(self.batch_size, self.seq_length, self.vocab_size)      )




														def 	__snake_case(						self   :					List[str]	,							_UpperCamelCase   :					Any	,							_UpperCamelCase   :					Tuple	,							_UpperCamelCase   :					str	,							_UpperCamelCase   :					Optional[int]	,							_UpperCamelCase   :					Union[str, Any]	,							_UpperCamelCase   :					Union[str, Any]	,							_UpperCamelCase   :					int      )					->				List[str]:



																			'''simple docstring'''

																			SCREAMING_SNAKE_CASE    			=       TFMobileBertForNextSentencePrediction(config=_UpperCamelCase      )
																			SCREAMING_SNAKE_CASE    			=       {"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
																			SCREAMING_SNAKE_CASE    			=       model(_UpperCamelCase      )
																			self.parent.assertEqual(result.logits.shape	,							(self.batch_size, 2)      )




														def 	__snake_case(						self   :					List[Any]	,							_UpperCamelCase   :					Optional[Any]	,							_UpperCamelCase   :					Union[str, Any]	,							_UpperCamelCase   :					Optional[Any]	,							_UpperCamelCase   :					int	,							_UpperCamelCase   :					str	,							_UpperCamelCase   :					Tuple	,							_UpperCamelCase   :					Union[str, Any]      )					->				Tuple:



																			'''simple docstring'''

																			SCREAMING_SNAKE_CASE    			=       TFMobileBertForPreTraining(config=_UpperCamelCase      )
																			SCREAMING_SNAKE_CASE    			=       {"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
																			SCREAMING_SNAKE_CASE    			=       model(_UpperCamelCase      )
																			self.parent.assertEqual(
																			    result.prediction_logits.shape	,							(self.batch_size, self.seq_length, self.vocab_size)      )
																			self.parent.assertEqual(result.seq_relationship_logits.shape	,							(self.batch_size, 2)      )




														def 	__snake_case(						self   :					List[str]	,							_UpperCamelCase   :					Dict	,							_UpperCamelCase   :					Optional[int]	,							_UpperCamelCase   :					int	,							_UpperCamelCase   :					Any	,							_UpperCamelCase   :					Tuple	,							_UpperCamelCase   :					List[Any]	,							_UpperCamelCase   :					Optional[int]      )					->				Optional[int]:



																			'''simple docstring'''

																			SCREAMING_SNAKE_CASE    			=       self.num_labels
																			SCREAMING_SNAKE_CASE    			=       TFMobileBertForSequenceClassification(config=_UpperCamelCase      )
																			SCREAMING_SNAKE_CASE    			=       {"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
																			SCREAMING_SNAKE_CASE    			=       model(_UpperCamelCase      )
																			self.parent.assertEqual(result.logits.shape	,							(self.batch_size, self.num_labels)      )




														def 	__snake_case(						self   :					Dict	,							_UpperCamelCase   :					str	,							_UpperCamelCase   :					Union[str, Any]	,							_UpperCamelCase   :					Tuple	,							_UpperCamelCase   :					Tuple	,							_UpperCamelCase   :					Union[str, Any]	,							_UpperCamelCase   :					Optional[int]	,							_UpperCamelCase   :					Any      )					->				List[Any]:



																			'''simple docstring'''

																			SCREAMING_SNAKE_CASE    			=       self.num_choices
																			SCREAMING_SNAKE_CASE    			=       TFMobileBertForMultipleChoice(config=_UpperCamelCase      )
																			SCREAMING_SNAKE_CASE    			=       tf.tile(tf.expand_dims(_UpperCamelCase	,							1      )	,							(1, self.num_choices, 1)      )
																			SCREAMING_SNAKE_CASE    			=       tf.tile(tf.expand_dims(_UpperCamelCase	,							1      )	,							(1, self.num_choices, 1)      )
																			SCREAMING_SNAKE_CASE    			=       tf.tile(tf.expand_dims(_UpperCamelCase	,							1      )	,							(1, self.num_choices, 1)      )
																			SCREAMING_SNAKE_CASE    			=       {
																			    "input_ids": multiple_choice_inputs_ids,
																			    "attention_mask": multiple_choice_input_mask,
																			    "token_type_ids": multiple_choice_token_type_ids,
																			}
																			SCREAMING_SNAKE_CASE    			=       model(_UpperCamelCase      )
																			self.parent.assertEqual(result.logits.shape	,							(self.batch_size, self.num_choices)      )




														def 	__snake_case(						self   :					Tuple	,							_UpperCamelCase   :					Any	,							_UpperCamelCase   :					Any	,							_UpperCamelCase   :					Union[str, Any]	,							_UpperCamelCase   :					Optional[int]	,							_UpperCamelCase   :					Optional[Any]	,							_UpperCamelCase   :					List[Any]	,							_UpperCamelCase   :					Optional[Any]      )					->				Dict:



																			'''simple docstring'''

																			SCREAMING_SNAKE_CASE    			=       self.num_labels
																			SCREAMING_SNAKE_CASE    			=       TFMobileBertForTokenClassification(config=_UpperCamelCase      )
																			SCREAMING_SNAKE_CASE    			=       {"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
																			SCREAMING_SNAKE_CASE    			=       model(_UpperCamelCase      )
																			self.parent.assertEqual(result.logits.shape	,							(self.batch_size, self.seq_length, self.num_labels)      )




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



																			'''simple docstring'''

																			SCREAMING_SNAKE_CASE    			=       TFMobileBertForQuestionAnswering(config=_UpperCamelCase      )
																			SCREAMING_SNAKE_CASE    			=       {"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
																			SCREAMING_SNAKE_CASE    			=       model(_UpperCamelCase      )
																			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 	__snake_case(						self   :					List[str]      )					->				Any:



																			'''simple docstring'''

																			SCREAMING_SNAKE_CASE    			=       self.prepare_config_and_inputs()
																			(
																			    (
																			    SCREAMING_SNAKE_CASE   
																			)			,   (
																			    SCREAMING_SNAKE_CASE   
																			)			,   (
																			    SCREAMING_SNAKE_CASE   
																			)			,   (
																			    SCREAMING_SNAKE_CASE   
																			)			,   (
																			    SCREAMING_SNAKE_CASE   
																			)			,   (
																			    SCREAMING_SNAKE_CASE   
																			)			,   (
																			    SCREAMING_SNAKE_CASE   
																			)			,      
																			)    			=       config_and_inputs
																			SCREAMING_SNAKE_CASE    			=       {"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
																			return config, inputs_dict




							def 	__snake_case(						self   :					Optional[Any]      )					->				Union[str, Any]:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       TFMobileBertModelTest.TFMobileBertModelTester(self      )
												SCREAMING_SNAKE_CASE    			=       ConfigTester(self	,							config_class=_UpperCamelCase	,							hidden_size=37      )




							def 	__snake_case(						self   :					Dict      )					->				Any:



												'''simple docstring'''

												self.config_tester.run_common_tests()




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



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_mobilebert_model(*_UpperCamelCase      )




							def 	__snake_case(						self   :					Optional[int]      )					->				Optional[int]:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_mobilebert_for_masked_lm(*_UpperCamelCase      )




							def 	__snake_case(						self   :					Any      )					->				Dict:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_mobilebert_for_multiple_choice(*_UpperCamelCase      )




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



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_mobilebert_for_next_sequence_prediction(*_UpperCamelCase      )




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



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_mobilebert_for_pretraining(*_UpperCamelCase      )




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



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_mobilebert_for_question_answering(*_UpperCamelCase      )




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



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_mobilebert_for_sequence_classification(*_UpperCamelCase      )




							def 	__snake_case(						self   :					str      )					->				List[str]:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_mobilebert_for_token_classification(*_UpperCamelCase      )





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



												'''simple docstring'''

												for model_name in ["google/mobilebert-uncased"]:
																	SCREAMING_SNAKE_CASE    			=       TFMobileBertModel.from_pretrained(_UpperCamelCase      )
																	self.assertIsNotNone(_UpperCamelCase      )



@require_tf
class 						lowercase    (     unittest.TestCase     ):




							@slow
							def 	__snake_case(						self   :					List[str]      )					->				Any:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       TFMobileBertForPreTraining.from_pretrained("google/mobilebert-uncased"      )
												SCREAMING_SNAKE_CASE    			=       tf.constant([[0, 1, 2, 3, 4, 5]]      )
												SCREAMING_SNAKE_CASE    			=       model(_UpperCamelCase      )[0]

												SCREAMING_SNAKE_CASE    			=       [1, 6, 30_522]
												self.assertEqual(output.shape	,							_UpperCamelCase      )

												SCREAMING_SNAKE_CASE    			=       tf.constant(
												    [
												        [
												            [-4.5_9_1_9_5_4_7, -9.2_4_8_2_9_5, -9.6_4_5_2_5_6],
												            [-6.7_3_0_6_1_7_5, -6.4_4_0_2_8_4, -6.6_0_5_2_8_3_7],
												            [-7.2_7_4_3_5_0_6, -6.7_8_4_7_9_1_5, -6.0_2_4_6_7_3],
												        ]
												    ]      )
												tf.debugging.assert_near(output[:, :3, :3]	,							_UpperCamelCase	,							atol=1e-4      )





import unittest

import numpy as np

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

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
							import torch

if is_vision_available():
							from PIL import Image

							from transformers import DPTImageProcessor


class 						lowercase    (     unittest.TestCase     ):




							def __init__(						self   :					Union[str, Any]	,							_UpperCamelCase   :					Tuple	,							_UpperCamelCase   :					List[Any]=7	,							_UpperCamelCase   :					Any=3	,							_UpperCamelCase   :					str=18	,							_UpperCamelCase   :					Tuple=30	,							_UpperCamelCase   :					Optional[int]=400	,							_UpperCamelCase   :					Optional[int]=True	,							_UpperCamelCase   :					Optional[Any]=None	,							_UpperCamelCase   :					int=True	,							_UpperCamelCase   :					Optional[int]=[0.5, 0.5, 0.5]	,							_UpperCamelCase   :					List[str]=[0.5, 0.5, 0.5]	,							)					->				str:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       size if size is not None else {"height": 18, "width": 18}
												SCREAMING_SNAKE_CASE    			=       parent
												SCREAMING_SNAKE_CASE    			=       batch_size
												SCREAMING_SNAKE_CASE    			=       num_channels
												SCREAMING_SNAKE_CASE    			=       image_size
												SCREAMING_SNAKE_CASE    			=       min_resolution
												SCREAMING_SNAKE_CASE    			=       max_resolution
												SCREAMING_SNAKE_CASE    			=       do_resize
												SCREAMING_SNAKE_CASE    			=       size
												SCREAMING_SNAKE_CASE    			=       do_normalize
												SCREAMING_SNAKE_CASE    			=       image_mean
												SCREAMING_SNAKE_CASE    			=       image_std





							def 	__snake_case(						self   :					List[Any]      )					->				Any:



												'''simple docstring'''

												return {
												    "image_mean": self.image_mean,
												    "image_std": self.image_std,
												    "do_normalize": self.do_normalize,
												    "do_resize": self.do_resize,
												    "size": self.size,
												}



@require_torch
@require_vision
class 						lowercase    (     a				,       unittest.TestCase     ):
							lowercase__						:       Any								=							DPTImageProcessor if is_vision_available() else None




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



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       DPTImageProcessingTester(self      )




							@property
							def 	__snake_case(						self   :					List[Any]      )					->				List[str]:



												'''simple docstring'''

												return self.image_processor_tester.prepare_image_processor_dict()




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



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       self.image_processing_class(**self.image_processor_dict      )
												self.assertTrue(hasattr(_UpperCamelCase	,							"image_mean"      )      )
												self.assertTrue(hasattr(_UpperCamelCase	,							"image_std"      )      )
												self.assertTrue(hasattr(_UpperCamelCase	,							"do_normalize"      )      )
												self.assertTrue(hasattr(_UpperCamelCase	,							"do_resize"      )      )
												self.assertTrue(hasattr(_UpperCamelCase	,							"size"      )      )




							def 	__snake_case(						self   :					Dict      )					->				Dict:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       self.image_processing_class.from_dict(self.image_processor_dict      )
												self.assertEqual(image_processor.size	,							{"height": 18, "width": 18}      )

												SCREAMING_SNAKE_CASE    			=       self.image_processing_class.from_dict(self.image_processor_dict	,							size=42      )
												self.assertEqual(image_processor.size	,							{"height": 42, "width": 42}      )




							def 	__snake_case(						self   :					Union[str, Any]      )					->				Tuple:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       self.image_processing_class(**self.image_processor_dict      )
												# create random PIL images
												SCREAMING_SNAKE_CASE    			=       prepare_image_inputs(self.image_processor_tester	,							equal_resolution=_UpperCamelCase      )
												for image in image_inputs:
																	self.assertIsInstance(_UpperCamelCase	,							Image.Image      )

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

												# Test batched
												SCREAMING_SNAKE_CASE    			=       image_processing(_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 	__snake_case(						self   :					Optional[Any]      )					->				Optional[Any]:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       self.image_processing_class(**self.image_processor_dict      )
												# create random numpy tensors
												SCREAMING_SNAKE_CASE    			=       prepare_image_inputs(self.image_processor_tester	,							equal_resolution=_UpperCamelCase	,							numpify=_UpperCamelCase      )
												for image in image_inputs:
																	self.assertIsInstance(_UpperCamelCase	,							np.ndarray      )

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

												# Test batched
												SCREAMING_SNAKE_CASE    			=       image_processing(_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 	__snake_case(						self   :					Optional[Any]      )					->				str:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       self.image_processing_class(**self.image_processor_dict      )
												# create random PyTorch tensors
												SCREAMING_SNAKE_CASE    			=       prepare_image_inputs(self.image_processor_tester	,							equal_resolution=_UpperCamelCase	,							torchify=_UpperCamelCase      )
												for image in image_inputs:
																	self.assertIsInstance(_UpperCamelCase	,							torch.Tensor      )

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

												# Test batched
												SCREAMING_SNAKE_CASE    			=       image_processing(_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"],
												    )	,							)




