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				     =   (
     (
         TFMobileBertModel,
         TFMobileBertForMaskedLM,
         TFMobileBertForNextSentencePrediction,
         TFMobileBertForPreTraining,
         TFMobileBertForQuestionAnswering,
         TFMobileBertForSequenceClassification,
         TFMobileBertForTokenClassification,
         TFMobileBertForMultipleChoice,
     )
     if is_tf_available()
     else ()
 )
 lowercase				     =   (
     {
         """feature-extraction""": TFMobileBertModel,
         """fill-mask""": TFMobileBertForMaskedLM,
         """question-answering""": TFMobileBertForQuestionAnswering,
         """text-classification""": TFMobileBertForSequenceClassification,
         """token-classification""": TFMobileBertForTokenClassification,
         """zero-shot""": TFMobileBertForSequenceClassification,
     }
     if is_tf_available()
     else {}
 )
 lowercase				     =   False
 lowercase				     =   False

 def 						SCREAMING_SNAKE_CASE__   ( self	:							List[Any]   ,      snake_case	:							List[Any]   ,      snake_case	:							int   ,      snake_case	:							int=False			)   ->						List[str]:

  """simple docstring"""





  UpperCamelCase_					:						Dict =					super()._prepare_for_class(__lowerCamelCase   ,      __lowerCamelCase   ,      return_labels=__lowerCamelCase			)

  if return_labels:
   if model_class in get_values(__lowerCamelCase			):
    UpperCamelCase_					:						List[Any] =					tf.zeros(self.model_tester.batch_size   ,      dtype=tf.intaa			)

  return inputs_dict





 class 		_lowercase						(					_a       ):

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

   """simple docstring"""





   UpperCamelCase_					:						Optional[int] =					parent
   UpperCamelCase_					:						str =					batch_size
   UpperCamelCase_					:						Optional[int] =					seq_length
   UpperCamelCase_					:						Optional[Any] =					is_training
   UpperCamelCase_					:						List[str] =					use_input_mask
   UpperCamelCase_					:						Union[str, Any] =					use_token_type_ids
   UpperCamelCase_					:						Tuple =					use_labels
   UpperCamelCase_					:						Union[str, Any] =					vocab_size
   UpperCamelCase_					:						Optional[Any] =					hidden_size
   UpperCamelCase_					:						Any =					num_hidden_layers
   UpperCamelCase_					:						List[str] =					num_attention_heads
   UpperCamelCase_					:						List[str] =					intermediate_size
   UpperCamelCase_					:						int =					hidden_act
   UpperCamelCase_					:						Any =					hidden_dropout_prob
   UpperCamelCase_					:						int =					attention_probs_dropout_prob
   UpperCamelCase_					:						str =					max_position_embeddings
   UpperCamelCase_					:						str =					type_vocab_size
   UpperCamelCase_					:						Union[str, Any] =					type_sequence_label_size
   UpperCamelCase_					:						Tuple =					initializer_range
   UpperCamelCase_					:						List[Any] =					num_labels
   UpperCamelCase_					:						Union[str, Any] =					num_choices
   UpperCamelCase_					:						List[Any] =					scope
   UpperCamelCase_					:						Any =					embedding_size

  def 						SCREAMING_SNAKE_CASE__   ( self	:							Dict			)   ->						int:

   """simple docstring"""





   UpperCamelCase_					:						Dict =					ids_tensor([self.batch_size, self.seq_length]   ,      self.vocab_size			)

   UpperCamelCase_					:						List[Any] =					None
   if self.use_input_mask:
    UpperCamelCase_					:						Optional[int] =					random_attention_mask([self.batch_size, self.seq_length]			)

   UpperCamelCase_					:						Tuple =					None
   if self.use_token_type_ids:
    UpperCamelCase_					:						Optional[int] =					ids_tensor([self.batch_size, self.seq_length]   ,      self.type_vocab_size			)

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

   UpperCamelCase_					:						Union[str, Any] =					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 						SCREAMING_SNAKE_CASE__   ( self	:							List[str]   ,      snake_case	:							Union[str, Any]   ,      snake_case	:							Optional[Any]   ,      snake_case	:							Optional[Any]   ,      snake_case	:							Optional[int]   ,      snake_case	:							List[Any]   ,      snake_case	:							List[Any]   ,      snake_case	:							Dict			)   ->						List[str]:

   """simple docstring"""





   UpperCamelCase_					:						Dict =					TFMobileBertModel(config=__lowerCamelCase			)
   UpperCamelCase_					:						Optional[int] =					{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
   UpperCamelCase_					:						str =					model(__lowerCamelCase			)

   UpperCamelCase_					:						Any =					[input_ids, input_mask]
   UpperCamelCase_					:						Dict =					model(__lowerCamelCase			)

   UpperCamelCase_					:						int =					model(__lowerCamelCase			)

   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 						SCREAMING_SNAKE_CASE__   ( self	:							Any   ,      snake_case	:							Optional[int]   ,      snake_case	:							Dict   ,      snake_case	:							Dict   ,      snake_case	:							Optional[int]   ,      snake_case	:							Optional[int]   ,      snake_case	:							Optional[Any]   ,      snake_case	:							List[Any]			)   ->						List[Any]:

   """simple docstring"""





   UpperCamelCase_					:						Optional[Any] =					TFMobileBertForMaskedLM(config=__lowerCamelCase			)
   UpperCamelCase_					:						int =					{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
   UpperCamelCase_					:						Dict =					model(__lowerCamelCase			)
   self.parent.assertEqual(result.logits.shape   ,      (self.batch_size, self.seq_length, self.vocab_size)			)

  def 						SCREAMING_SNAKE_CASE__   ( self	:							int   ,      snake_case	:							Tuple   ,      snake_case	:							Tuple   ,      snake_case	:							Union[str, Any]   ,      snake_case	:							str   ,      snake_case	:							str   ,      snake_case	:							List[str]   ,      snake_case	:							int			)   ->						Any:

   """simple docstring"""





   UpperCamelCase_					:						str =					TFMobileBertForNextSentencePrediction(config=__lowerCamelCase			)
   UpperCamelCase_					:						Optional[int] =					{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
   UpperCamelCase_					:						int =					model(__lowerCamelCase			)
   self.parent.assertEqual(result.logits.shape   ,      (self.batch_size, 2)			)

  def 						SCREAMING_SNAKE_CASE__   ( self	:							Optional[Any]   ,      snake_case	:							str   ,      snake_case	:							str   ,      snake_case	:							Dict   ,      snake_case	:							int   ,      snake_case	:							Optional[Any]   ,      snake_case	:							Optional[int]   ,      snake_case	:							Union[str, Any]			)   ->						Dict:

   """simple docstring"""





   UpperCamelCase_					:						Optional[int] =					TFMobileBertForPreTraining(config=__lowerCamelCase			)
   UpperCamelCase_					:						Any =					{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
   UpperCamelCase_					:						Any =					model(__lowerCamelCase			)
   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 						SCREAMING_SNAKE_CASE__   ( self	:							Optional[int]   ,      snake_case	:							Union[str, Any]   ,      snake_case	:							Any   ,      snake_case	:							List[str]   ,      snake_case	:							Optional[Any]   ,      snake_case	:							List[str]   ,      snake_case	:							Optional[Any]   ,      snake_case	:							Any			)   ->						Optional[Any]:

   """simple docstring"""





   UpperCamelCase_					:						int =					self.num_labels
   UpperCamelCase_					:						Union[str, Any] =					TFMobileBertForSequenceClassification(config=__lowerCamelCase			)
   UpperCamelCase_					:						Union[str, Any] =					{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
   UpperCamelCase_					:						List[str] =					model(__lowerCamelCase			)
   self.parent.assertEqual(result.logits.shape   ,      (self.batch_size, self.num_labels)			)

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

   """simple docstring"""





   UpperCamelCase_					:						str =					self.num_choices
   UpperCamelCase_					:						List[str] =					TFMobileBertForMultipleChoice(config=__lowerCamelCase			)
   UpperCamelCase_					:						Dict =					tf.tile(tf.expand_dims(__lowerCamelCase   ,      1			)   ,      (1, self.num_choices, 1)			)
   UpperCamelCase_					:						Tuple =					tf.tile(tf.expand_dims(__lowerCamelCase   ,      1			)   ,      (1, self.num_choices, 1)			)
   UpperCamelCase_					:						Optional[Any] =					tf.tile(tf.expand_dims(__lowerCamelCase   ,      1			)   ,      (1, self.num_choices, 1)			)
   UpperCamelCase_					:						int =					{
       """input_ids""": multiple_choice_inputs_ids,
       """attention_mask""": multiple_choice_input_mask,
       """token_type_ids""": multiple_choice_token_type_ids,
   }
   UpperCamelCase_					:						List[str] =					model(__lowerCamelCase			)
   self.parent.assertEqual(result.logits.shape   ,      (self.batch_size, self.num_choices)			)

  def 						SCREAMING_SNAKE_CASE__   ( self	:							int   ,      snake_case	:							Optional[Any]   ,      snake_case	:							str   ,      snake_case	:							Dict   ,      snake_case	:							int   ,      snake_case	:							Optional[Any]   ,      snake_case	:							Dict   ,      snake_case	:							Dict			)   ->						Tuple:

   """simple docstring"""





   UpperCamelCase_					:						str =					self.num_labels
   UpperCamelCase_					:						int =					TFMobileBertForTokenClassification(config=__lowerCamelCase			)
   UpperCamelCase_					:						Dict =					{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
   UpperCamelCase_					:						Tuple =					model(__lowerCamelCase			)
   self.parent.assertEqual(result.logits.shape   ,      (self.batch_size, self.seq_length, self.num_labels)			)

  def 						SCREAMING_SNAKE_CASE__   ( self	:							int   ,      snake_case	:							List[Any]   ,      snake_case	:							str   ,      snake_case	:							Dict   ,      snake_case	:							Optional[Any]   ,      snake_case	:							Optional[int]   ,      snake_case	:							Optional[int]   ,      snake_case	:							Any			)   ->						List[Any]:

   """simple docstring"""





   UpperCamelCase_					:						Union[str, Any] =					TFMobileBertForQuestionAnswering(config=__lowerCamelCase			)
   UpperCamelCase_					:						Tuple =					{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
   UpperCamelCase_					:						Tuple =					model(__lowerCamelCase			)
   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 						SCREAMING_SNAKE_CASE__   ( self	:							str			)   ->						int:

   """simple docstring"""





   UpperCamelCase_					:						Tuple =					self.prepare_config_and_inputs()
   (
       UpperCamelCase_      
   )					:						Dict =					config_and_inputs
   UpperCamelCase_					:						Optional[Any] =					{"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
   return config, inputs_dict

 def 						SCREAMING_SNAKE_CASE__   ( self	:							Tuple			)   ->						Any:

  """simple docstring"""





  UpperCamelCase_					:						int =					TFMobileBertModelTest.TFMobileBertModelTester(self			)
  UpperCamelCase_					:						Dict =					ConfigTester(self   ,      config_class=__lowerCamelCase   ,      hidden_size=3_7			)

 def 						SCREAMING_SNAKE_CASE__   ( self	:							int			)   ->						Dict:

  """simple docstring"""





  self.config_tester.run_common_tests()

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

  """simple docstring"""





  UpperCamelCase_					:						Dict =					self.model_tester.prepare_config_and_inputs()
  self.model_tester.create_and_check_mobilebert_model(*__lowerCamelCase			)

 def 						SCREAMING_SNAKE_CASE__   ( self	:							Optional[Any]			)   ->						str:

  """simple docstring"""





  UpperCamelCase_					:						Tuple =					self.model_tester.prepare_config_and_inputs()
  self.model_tester.create_and_check_mobilebert_for_masked_lm(*__lowerCamelCase			)

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

  """simple docstring"""





  UpperCamelCase_					:						int =					self.model_tester.prepare_config_and_inputs()
  self.model_tester.create_and_check_mobilebert_for_multiple_choice(*__lowerCamelCase			)

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

  """simple docstring"""





  UpperCamelCase_					:						Union[str, Any] =					self.model_tester.prepare_config_and_inputs()
  self.model_tester.create_and_check_mobilebert_for_next_sequence_prediction(*__lowerCamelCase			)

 def 						SCREAMING_SNAKE_CASE__   ( self	:							Dict			)   ->						Optional[int]:

  """simple docstring"""





  UpperCamelCase_					:						str =					self.model_tester.prepare_config_and_inputs()
  self.model_tester.create_and_check_mobilebert_for_pretraining(*__lowerCamelCase			)

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

  """simple docstring"""





  UpperCamelCase_					:						Dict =					self.model_tester.prepare_config_and_inputs()
  self.model_tester.create_and_check_mobilebert_for_question_answering(*__lowerCamelCase			)

 def 						SCREAMING_SNAKE_CASE__   ( self	:							Tuple			)   ->						Tuple:

  """simple docstring"""





  UpperCamelCase_					:						Union[str, Any] =					self.model_tester.prepare_config_and_inputs()
  self.model_tester.create_and_check_mobilebert_for_sequence_classification(*__lowerCamelCase			)

 def 						SCREAMING_SNAKE_CASE__   ( self	:							Any			)   ->						Tuple:

  """simple docstring"""





  UpperCamelCase_					:						str =					self.model_tester.prepare_config_and_inputs()
  self.model_tester.create_and_check_mobilebert_for_token_classification(*__lowerCamelCase			)


 @slow
 def 						SCREAMING_SNAKE_CASE__   ( self	:							int			)   ->						int:

  """simple docstring"""





  for model_name in ["google/mobilebert-uncased"]:
   UpperCamelCase_					:						Optional[int] =					TFMobileBertModel.from_pretrained(__lowerCamelCase			)
   self.assertIsNotNone(__lowerCamelCase			)





@require_tf
class 		_lowercase						(					unittest.TestCase       ):

 @slow
 def 						SCREAMING_SNAKE_CASE__   ( self	:							Tuple			)   ->						Optional[Any]:

  """simple docstring"""





  UpperCamelCase_					:						List[Any] =					TFMobileBertForPreTraining.from_pretrained('google/mobilebert-uncased'			)
  UpperCamelCase_					:						str =					tf.constant([[0, 1, 2, 3, 4, 5]]			)
  UpperCamelCase_					:						Dict =					model(__lowerCamelCase			)[0]

  UpperCamelCase_					:						str =					[1, 6, 3_0_5_2_2]
  self.assertEqual(output.shape   ,      __lowerCamelCase			)

  UpperCamelCase_					:						int =					tf.constant(
      [
          [
              [-4.5919547, -9.248295, -9.645256],
              [-6.7306175, -6.440284, -6.6052837],
              [-7.2743506, -6.7847915, -6.024673],
          ]
      ]			)
  tf.debugging.assert_near(output[:, :3, :3]   ,      __lowerCamelCase   ,      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, prepare_image_inputs


if is_torch_available():
	import torch

if is_vision_available():
	from PIL import Image

	from transformers import ViTImageProcessor

class     _SCREAMING_SNAKE_CASE       (			unittest.TestCase      ):





	def __init__(		self				:					List[str] ,  __lowerCamelCase				:					Optional[Any] ,  __lowerCamelCase				:					Any=13 ,  __lowerCamelCase				:					Dict=3 ,  __lowerCamelCase				:					int=224 ,  __lowerCamelCase				:					Any=30 ,  __lowerCamelCase				:					Tuple=400 ,  __lowerCamelCase				:					int=True ,  __lowerCamelCase				:					List[str]=None ,  __lowerCamelCase				:					Any=True ,  __lowerCamelCase				:					Dict=[0.5, 0.5, 0.5] ,  __lowerCamelCase				:					List[Any]=[0.5, 0.5, 0.5] ,  ):
		UpperCamelCase     :List[Any]          =	size if size is not None else {"""height""": 18, """width""": 18}
		UpperCamelCase     :str          =	parent
		UpperCamelCase     :Optional[int]          =	batch_size
		UpperCamelCase     :Dict          =	num_channels
		UpperCamelCase     :str          =	image_size
		UpperCamelCase     :Dict          =	min_resolution
		UpperCamelCase     :str          =	max_resolution
		UpperCamelCase     :Union[str, Any]          =	do_resize
		UpperCamelCase     :Optional[Any]          =	size
		UpperCamelCase     :Any          =	do_normalize
		UpperCamelCase     :Optional[Any]          =	image_mean
		UpperCamelCase     :Tuple          =	image_std





	def 						_A (		self				:					int	):
		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     _SCREAMING_SNAKE_CASE       (			_a		,   unittest.TestCase      ):
	snake_case__							:     List[Any]     	=  ViTImageProcessor if is_vision_available() else None





	def 						_A (		self				:					str	):
		UpperCamelCase     :Tuple          =	EfficientFormerImageProcessorTester(self	)





	@property
	def 						_A (		self				:					List[str]	):
		return self.image_proc_tester.prepare_image_processor_dict()





	def 						_A (		self				:					int	):
		UpperCamelCase     :List[Any]          =	self.image_processing_class(**self.image_processor_dict	)
		self.assertTrue(hasattr(__lowerCamelCase ,  """image_mean"""	)	)
		self.assertTrue(hasattr(__lowerCamelCase ,  """image_std"""	)	)
		self.assertTrue(hasattr(__lowerCamelCase ,  """do_normalize"""	)	)
		self.assertTrue(hasattr(__lowerCamelCase ,  """do_resize"""	)	)
		self.assertTrue(hasattr(__lowerCamelCase ,  """size"""	)	)





	def 						_A (		self				:					Optional[int]	):
		pass





	def 						_A (		self				:					str	):
		# Initialize image_processor
		UpperCamelCase     :Union[str, Any]          =	self.image_processing_class(**self.image_processor_dict	)
		# create random PIL images
		UpperCamelCase     :Union[str, Any]          =	prepare_image_inputs(self.image_proc_tester ,  equal_resolution=__lowerCamelCase	)
		for image in image_inputs:
			self.assertIsInstance(__lowerCamelCase ,  Image.Image	)

		# Test not batched input
		UpperCamelCase     :List[str]          =	image_processor(image_inputs[0] ,  return_tensors="""pt"""	).pixel_values
		self.assertEqual(
		    encoded_images.shape ,  (
		        1,
		        self.image_proc_tester.num_channels,
		        self.image_proc_tester.size["""height"""],
		        self.image_proc_tester.size["""width"""],
		    ) ,  )

		# Test batched
		UpperCamelCase     :List[Any]          =	image_processor(__lowerCamelCase ,  return_tensors="""pt"""	).pixel_values
		self.assertEqual(
		    encoded_images.shape ,  (
		        self.image_proc_tester.batch_size,
		        self.image_proc_tester.num_channels,
		        self.image_proc_tester.size["""height"""],
		        self.image_proc_tester.size["""width"""],
		    ) ,  )





	def 						_A (		self				:					Union[str, Any]	):
		# Initialize image_processor
		UpperCamelCase     :Optional[int]          =	self.image_processing_class(**self.image_processor_dict	)
		# create random numpy tensors
		UpperCamelCase     :List[Any]          =	prepare_image_inputs(self.image_proc_tester ,  equal_resolution=__lowerCamelCase ,  numpify=__lowerCamelCase	)
		for image in image_inputs:
			self.assertIsInstance(__lowerCamelCase ,  np.ndarray	)

		# Test not batched input
		UpperCamelCase     :Dict          =	image_processor(image_inputs[0] ,  return_tensors="""pt"""	).pixel_values
		self.assertEqual(
		    encoded_images.shape ,  (
		        1,
		        self.image_proc_tester.num_channels,
		        self.image_proc_tester.size["""height"""],
		        self.image_proc_tester.size["""width"""],
		    ) ,  )

		# Test batched
		UpperCamelCase     :Tuple          =	image_processor(__lowerCamelCase ,  return_tensors="""pt"""	).pixel_values
		self.assertEqual(
		    encoded_images.shape ,  (
		        self.image_proc_tester.batch_size,
		        self.image_proc_tester.num_channels,
		        self.image_proc_tester.size["""height"""],
		        self.image_proc_tester.size["""width"""],
		    ) ,  )





	def 						_A (		self				:					List[Any]	):
		# Initialize image_processor
		UpperCamelCase     :List[str]          =	self.image_processing_class(**self.image_processor_dict	)
		# create random PyTorch tensors
		UpperCamelCase     :Any          =	prepare_image_inputs(self.image_proc_tester ,  equal_resolution=__lowerCamelCase ,  torchify=__lowerCamelCase	)
		for image in image_inputs:
			self.assertIsInstance(__lowerCamelCase ,  torch.Tensor	)

		# Test not batched input
		UpperCamelCase     :List[Any]          =	image_processor(image_inputs[0] ,  return_tensors="""pt"""	).pixel_values
		self.assertEqual(
		    encoded_images.shape ,  (
		        1,
		        self.image_proc_tester.num_channels,
		        self.image_proc_tester.size["""height"""],
		        self.image_proc_tester.size["""width"""],
		    ) ,  )

		# Test batched
		UpperCamelCase     :str          =	image_processor(__lowerCamelCase ,  return_tensors="""pt"""	).pixel_values
		self.assertEqual(
		    encoded_images.shape ,  (
		        self.image_proc_tester.batch_size,
		        self.image_proc_tester.num_channels,
		        self.image_proc_tester.size["""height"""],
		        self.image_proc_tester.size["""width"""],
		    ) ,  )
