code: 
  
  from __future__ import annotations
  
  import inspect
  import unittest
  
  from transformers import MobileViTConfig
  from transformers.file_utils import is_tf_available, is_vision_available
  from transformers.testing_utils import require_tf, slow
  
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor
  from ...test_pipeline_mixin import PipelineTesterMixin
  
  
  if is_tf_available():
         import numpy as np
         import tensorflow as tf
  
         from transformers import TFMobileViTForImageClassification, TFMobileViTForSemanticSegmentation, TFMobileViTModel
         from transformers.models.mobilevit.modeling_tf_mobilevit import TF_MOBILEVIT_PRETRAINED_MODEL_ARCHIVE_LIST
  
  
  if is_vision_available():
         from PIL import Image
  
         from transformers import MobileViTImageProcessor
  
  
  
  
  
  
  
  class 		__magic_name__    (							snake_case_							):
  
     '''simple docstring'''
  
  
  
  
     def 				_UpperCAmelCase				(       self )							->					Dict:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=self.config_class(**self.inputs_dict )
       self.parent.assertTrue(hasattr(lowercase_,					'''hidden_sizes''' ) )
       self.parent.assertTrue(hasattr(lowercase_,					'''neck_hidden_sizes''' ) )
       self.parent.assertTrue(hasattr(lowercase_,					'''num_attention_heads''' ) )
  
  
  
  
  
  
  
  class 		__magic_name__    :
  
     '''simple docstring'''
  
  
  
  
     def __init__(       self,					lowercase_,					lowercase_=13,					lowercase_=32,					lowercase_=2,					lowercase_=3,					lowercase_=640,					lowercase_=4,					lowercase_="silu",					lowercase_=3,					lowercase_=32,					lowercase_=0.1,					lowercase_=0.1,					lowercase_=0.1,					lowercase_=0.02,					lowercase_=True,					lowercase_=True,					lowercase_=10,					lowercase_=None,					)							->					List[Any]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=parent
       a__						=batch_size
       a__						=image_size
       a__						=patch_size
       a__						=num_channels
       a__						=last_hidden_size
       a__						=num_attention_heads
       a__						=hidden_act
       a__						=conv_kernel_size
       a__						=output_stride
       a__						=hidden_dropout_prob
       a__						=attention_probs_dropout_prob
       a__						=classifier_dropout_prob
       a__						=use_labels
       a__						=is_training
       a__						=num_labels
       a__						=initializer_range
       a__						=scope
  
  
  
     def 				_UpperCAmelCase				(       self )							->					List[str]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size] )
  
       a__						=None
       a__						=None
       if self.use_labels:
         a__						=ids_tensor([self.batch_size],					self.num_labels )
         a__						=ids_tensor([self.batch_size, self.image_size, self.image_size],					self.num_labels )
  
       a__						=self.get_config()
  
       return config, pixel_values, labels, pixel_labels
  
  
  
     def 				_UpperCAmelCase				(       self )							->					Any:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       return MobileViTConfig(
           image_size=self.image_size,					patch_size=self.patch_size,					num_channels=self.num_channels,					num_attention_heads=self.num_attention_heads,					hidden_act=self.hidden_act,					conv_kernel_size=self.conv_kernel_size,					output_stride=self.output_stride,					hidden_dropout_prob=self.hidden_dropout_prob,					attention_probs_dropout_prob=self.attention_probs_dropout_prob,					classifier_dropout_prob=self.classifier_dropout_prob,					initializer_range=self.initializer_range,					)
  
  
  
     def 				_UpperCAmelCase				(       self,					lowercase_,					lowercase_,					lowercase_,					lowercase_ )							->					Optional[Any]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=TFMobileViTModel(config=lowercase_ )
       a__						=model(lowercase_,					training=lowercase_ )
       a__						=a__						=self.image_size // self.output_stride
       self.parent.assertEqual(
           result.last_hidden_state.shape,					(self.batch_size, self.last_hidden_size, expected_height, expected_width) )
  
  
  
     def 				_UpperCAmelCase				(       self,					lowercase_,					lowercase_,					lowercase_,					lowercase_ )							->					Dict:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=self.num_labels
       a__						=TFMobileViTForImageClassification(lowercase_ )
       a__						=model(lowercase_,					labels=lowercase_,					training=lowercase_ )
       self.parent.assertEqual(result.logits.shape,					(self.batch_size, self.num_labels) )
  
  
  
     def 				_UpperCAmelCase				(       self,					lowercase_,					lowercase_,					lowercase_,					lowercase_ )							->					Optional[int]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=self.num_labels
       a__						=TFMobileViTForSemanticSegmentation(lowercase_ )
       a__						=a__						=self.image_size // self.output_stride
  
       a__						=model(lowercase_,					training=lowercase_ )
       self.parent.assertEqual(
           result.logits.shape,					(self.batch_size, self.num_labels, expected_height, expected_width) )
  
       a__						=model(lowercase_,					labels=lowercase_,					training=lowercase_ )
       self.parent.assertEqual(
           result.logits.shape,					(self.batch_size, self.num_labels, expected_height, expected_width) )
  
  
  
     def 				_UpperCAmelCase				(       self )							->					List[str]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=self.prepare_config_and_inputs()
       a__,   a__,   a__,   a__						=config_and_inputs
       a__						={'''pixel_values''': pixel_values}
       return config, inputs_dict
  
  
  
  
  
  
  
  @require_tf
  class 		__magic_name__    (							snake_case_	, snake_case_	, unittest.TestCase							):
  
     '''simple docstring'''
  
  
  
  
     lowerCamelCase__				:			List[str]												=     (
         (TFMobileViTModel, TFMobileViTForImageClassification, TFMobileViTForSemanticSegmentation)
         if is_tf_available()
         else ()
     )
     lowerCamelCase__				:			Optional[Any]												=     (
         {'feature-extraction': TFMobileViTModel, 'image-classification': TFMobileViTForImageClassification}
         if is_tf_available()
         else {}
     )
  
     lowerCamelCase__				:			Any												=     False
     lowerCamelCase__				:			int												=     False
     lowerCamelCase__				:			int												=     False
     lowerCamelCase__				:			List[Any]												=     False
     lowerCamelCase__				:			Dict												=     False
  
  
  
     def 				_UpperCAmelCase				(       self )							->					List[str]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=TFMobileViTModelTester(self )
       a__						=TFMobileViTConfigTester(self,					config_class=lowercase_,					has_text_modality=lowercase_ )
  
  
  
     def 				_UpperCAmelCase				(       self )							->					Union[str, Any]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       self.config_tester.run_common_tests()
  
  
  
     @unittest.skip(reason='''MobileViT does not use inputs_embeds''' )
     def 				_UpperCAmelCase				(       self )							->					Any:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       pass
  
  
  
     @unittest.skip(reason='''MobileViT does not support input and output embeddings''' )
     def 				_UpperCAmelCase				(       self )							->					int:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       pass
  
  
  
     @unittest.skip(reason='''MobileViT does not output attentions''' )
     def 				_UpperCAmelCase				(       self )							->					List[Any]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       pass
  
  
  
     def 				_UpperCAmelCase				(       self )							->					Union[str, Any]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__,   a__						=self.model_tester.prepare_config_and_inputs_for_common()
  
       for model_class in self.all_model_classes:
         a__						=model_class(lowercase_ )
         a__						=inspect.signature(model.call )
         # signature.parameters is an OrderedDict => so arg_names order is deterministic
         a__						=[*signature.parameters.keys()]
  
         a__						=['''pixel_values''']
         self.assertListEqual(arg_names[:1],					lowercase_ )
  
  
  
     def 				_UpperCAmelCase				(       self )							->					List[Any]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_model(*lowercase_ )
  
  
  
     def 				_UpperCAmelCase				(       self )							->					Optional[Any]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       def check_hidden_states_output(lowercase_,					lowercase_,					lowercase_ ):
         a__						=model_class(lowercase_ )
  
         a__						=model(**self._prepare_for_class(lowercase_,					lowercase_ ) )
  
         a__						=outputs.hidden_states
  
         a__						=5
         self.assertEqual(len(lowercase_ ),					lowercase_ )
  
         # MobileViT's feature maps are of shape (batch_size, num_channels, height, width)
         # with the width and height being successively divided by 2.
         a__						=2
         for i in range(len(lowercase_ ) ):
           self.assertListEqual(
               list(hidden_states[i].shape[-2:] ),					[self.model_tester.image_size // divisor, self.model_tester.image_size // divisor],					)
           divisor *= 2
  
         self.assertEqual(self.model_tester.output_stride,					divisor // 2 )
  
       a__,   a__						=self.model_tester.prepare_config_and_inputs_for_common()
  
       for model_class in self.all_model_classes:
         a__						=True
         check_hidden_states_output(lowercase_,					lowercase_,					lowercase_ )
  
         # check that output_hidden_states also work using config
         del inputs_dict["output_hidden_states"]
         a__						=True
  
         check_hidden_states_output(lowercase_,					lowercase_,					lowercase_ )
  
  
  
     def 				_UpperCAmelCase				(       self )							->					Optional[int]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_image_classification(*lowercase_ )
  
  
  
     def 				_UpperCAmelCase				(       self )							->					List[Any]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_semantic_segmentation(*lowercase_ )
  
  
  
     @unittest.skipIf(
         not is_tf_available() or len(tf.config.list_physical_devices('''GPU''' ) ) == 0,					reason='''TF does not support backprop for grouped convolutions on CPU.''',					)
     def 				_UpperCAmelCase				(       self )							->					Any:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       super().test_dataset_conversion()
  
  
  
     def 				_UpperCAmelCase				(       self,					lowercase_,					lowercase_,					lowercase_=2E-1,					lowercase_=2E-1 )							->					List[str]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       self.assertTrue(np.allclose(lowercase_,					lowercase_,					atol=lowercase_,					rtol=lowercase_ ) )
  
  
  
     @unittest.skipIf(
         not is_tf_available() or len(tf.config.list_physical_devices('''GPU''' ) ) == 0,					reason='''TF does not support backprop for grouped convolutions on CPU.''',					)
     @slow
     def 				_UpperCAmelCase				(       self )							->					Dict:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__,   a__						=self.model_tester.prepare_config_and_inputs_for_common()
  
       for model_class in self.all_model_classes:
         # Since `TFMobileViTModel` cannot operate with the default `fit()` method.
         if model_class.__name__ != "TFMobileViTModel":
           a__						=model_class(lowercase_ )
           if getattr(lowercase_,					'''hf_compute_loss''',					lowercase_ ):
             super().test_keras_fit()
  
  
  
     def 				_UpperCAmelCase				(       self )							->					Optional[Any]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__,   a__						=self.model_tester.prepare_config_and_inputs_for_common()
       for model_class in self.all_model_classes:
         # set an ignore index to correctly test the masked loss used in
         # `TFMobileViTForSemanticSegmentation`.
         if model_class.__name__ != "TFMobileViTForSemanticSegmentation":
           a__						=5
  
         a__						=model_class(lowercase_ )
         if getattr(lowercase_,					'''hf_compute_loss''',					lowercase_ ):
           # The number of elements in the loss should be the same as the number of elements in the label
           a__						=self._prepare_for_class(inputs_dict.copy(),					lowercase_,					return_labels=lowercase_ )
           a__						=prepared_for_class[
               sorted(prepared_for_class.keys() - inputs_dict.keys(),					reverse=lowercase_ )[0]
           ]
           a__						=added_label.shape.as_list()[:1]
  
           # Test that model correctly compute the loss with kwargs
           a__						=self._prepare_for_class(inputs_dict.copy(),					lowercase_,					return_labels=lowercase_ )
           a__						={'''input_ids''', '''pixel_values''', '''input_features'''}
           a__						=possible_input_names.intersection(set(lowercase_ ) ).pop()
           a__						=prepared_for_class.pop(lowercase_ )
  
           a__						=model(lowercase_,					**lowercase_ )[0]
           self.assertTrue(loss.shape.as_list() == expected_loss_size or loss.shape.as_list() == [1] )
  
           # Test that model correctly compute the loss when we mask some positions
           a__						=self._prepare_for_class(inputs_dict.copy(),					lowercase_,					return_labels=lowercase_ )
           a__						={'''input_ids''', '''pixel_values''', '''input_features'''}
           a__						=possible_input_names.intersection(set(lowercase_ ) ).pop()
           a__						=prepared_for_class.pop(lowercase_ )
           if "labels" in prepared_for_class:
             a__						=prepared_for_class['''labels'''].numpy()
             if len(labels.shape ) > 1 and labels.shape[1] != 1:
               # labels[0] = -100
               a__						=tf.convert_to_tensor(lowercase_ )
               a__						=model(lowercase_,					**lowercase_ )[0]
               self.assertTrue(loss.shape.as_list() == expected_loss_size or loss.shape.as_list() == [1] )
               self.assertTrue(not np.any(np.isnan(loss.numpy() ) ) )
  
                  # Test that model correctly compute the loss with a dict
           a__						=self._prepare_for_class(inputs_dict.copy(),					lowercase_,					return_labels=lowercase_ )
           a__						=model(lowercase_ )[0]
           self.assertTrue(loss.shape.as_list() == expected_loss_size or loss.shape.as_list() == [1] )
  
           # Test that model correctly compute the loss with a tuple
           a__						=self._prepare_for_class(inputs_dict.copy(),					lowercase_,					return_labels=lowercase_ )
  
           # Get keys that were added with the _prepare_for_class function
           a__						=prepared_for_class.keys() - inputs_dict.keys()
           a__						=inspect.signature(model.call ).parameters
           a__						=list(signature.keys() )
  
           # Create a dictionary holding the location of the tensors in the tuple
           a__						={0: input_name}
           for label_key in label_keys:
             a__						=signature_names.index(lowercase_ )
             a__						=label_key
           a__						=sorted(tuple_index_mapping.items() )
           # Initialize a list with their default values, update the values and convert to a tuple
           a__						=[]
  
           for name in signature_names:
             if name != "kwargs":
               list_input.append(signature[name].default )
  
           for index, value in sorted_tuple_index_mapping:
             a__						=prepared_for_class[value]
  
           a__						=tuple(lowercase_ )
  
           # Send to model
           a__						=model(tuple_input[:-1] )[0]
  
           self.assertTrue(loss.shape.as_list() == expected_loss_size or loss.shape.as_list() == [1] )
  
  
  
     @slow
     def 				_UpperCAmelCase				(       self )							->					List[str]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       for model_name in TF_MOBILEVIT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
         a__						=TFMobileViTModel.from_pretrained(lowercase_ )
         self.assertIsNotNone(lowercase_ )
  
  
  
  
  
  def     UpperCAmelCase__       (    ):
  
  
  
  
  
    '''simple docstring'''
  
  
  
  
  
  
  
    a__						=Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''							)
    return image
  
  
  
  
  
  
  
  @require_tf
  class 		__magic_name__    (							unittest.TestCase							):
  
     '''simple docstring'''
  
  
  
  
     @slow
     def 				_UpperCAmelCase				(       self )							->					Optional[Any]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=TFMobileViTForImageClassification.from_pretrained('''apple/mobilevit-xx-small''' )
  
       a__						=MobileViTImageProcessor.from_pretrained('''apple/mobilevit-xx-small''' )
       a__						=prepare_img()
       a__						=image_processor(images=lowercase_,					return_tensors='''tf''' )
  
       # forward pass
       a__						=model(**lowercase_,					training=lowercase_ )
  
       # verify the logits
       a__						=tf.TensorShape((1, 1000) )
       self.assertEqual(outputs.logits.shape,					lowercase_ )
  
       a__						=tf.constant([-1.9364, -1.2327, -0.4653] )
  
       tf.debugging.assert_near(outputs.logits[0, :3],					lowercase_,					atol=1E-4,					rtol=1E-04 )
  
  
  
     @slow
     def 				_UpperCAmelCase				(       self )							->					Union[str, Any]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=TFMobileViTForSemanticSegmentation.from_pretrained('''apple/deeplabv3-mobilevit-xx-small''' )
  
       a__						=MobileViTImageProcessor.from_pretrained('''apple/deeplabv3-mobilevit-xx-small''' )
  
       a__						=prepare_img()
       a__						=image_processor(images=lowercase_,					return_tensors='''tf''' )
  
       # forward pass
       a__						=model(inputs.pixel_values,					training=lowercase_ )
       a__						=outputs.logits
  
       # verify the logits
       a__						=tf.TensorShape((1, 21, 32, 32) )
       self.assertEqual(logits.shape,					lowercase_ )
  
       a__						=tf.constant(
           [
               [[6.9713, 6.9786, 7.2422], [7.2893, 7.2825, 7.4446], [7.6580, 7.8797, 7.9420]],
               [[-10.6869, -10.3250, -10.3471], [-10.4228, -9.9868, -9.7132], [-11.0405, -11.0221, -10.7318]],
               [[-3.3089, -2.8539, -2.6740], [-3.2706, -2.5621, -2.5108], [-3.2534, -2.6615, -2.6651]],
           ] )
  
       tf.debugging.assert_near(logits[0, :3, :3, :3],					lowercase_,					rtol=1E-4,					atol=1E-4 )
  
style_context: 
  
  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 TvltImageProcessor
  
  
  
  
  def     UpperCAmelCase__       (    _A   :				Optional[int]			,   _A   :				List[Any]=10			,   _A   :				Optional[int]=10			,   _A   :				Dict=False			,   _A   :				Any=False							):
  
  
  
  
  
    '''simple docstring'''
  
  
  
  
  
  
  
    a__						=[]
    for i in range(image_processor_tester.num_frames							):
      video.append(np.random.randint(2_55			,   size=(image_processor_tester.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(_A			,   0			,   -1							)							) for frame in video]
  
    if torchify:
      a__						=[torch.from_numpy(_A							) for frame in video]
  
    return video
  
  
  
  
  def     UpperCAmelCase__       (    _A   :				List[str]			,   _A   :				Optional[int]=False			,   _A   :				Dict=False			,   _A   :				Optional[Any]=False							):
  
  
  
  
  
    '''simple docstring'''
  
  
  
  
  
  
  
    assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"
  
    a__						=[]
    for i in range(image_processor_tester.batch_size							):
      if equal_resolution:
        a__						=a__						=image_processor_tester.max_resolution
      else:
        a__,   a__						=np.random.choice(
            np.arange(image_processor_tester.min_resolution			,   image_processor_tester.max_resolution							)			,   2							)
        a__						=prepare_video(
            image_processor_tester=_A			,   width=_A			,   height=_A			,   numpify=_A			,   torchify=_A			,   )
      video_inputs.append(_A							)
  
    return video_inputs
  
  
  
  
  
  
  
  class 		__magic_name__    (							unittest.TestCase							):
  
     '''simple docstring'''
  
  
  
  
     def __init__(       self,					lowercase_,					lowercase_=7,					lowercase_=3,					lowercase_=4,					lowercase_=18,					lowercase_=30,					lowercase_=400,					lowercase_=True,					lowercase_=None,					lowercase_=True,					lowercase_=[0.5, 0.5, 0.5],					lowercase_=[0.5, 0.5, 0.5],					lowercase_=True,					lowercase_=None,					)							->					Optional[int]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=size if size is not None else {'''shortest_edge''': 18}
       a__						=crop_size if crop_size is not None else {'''height''': 18, '''width''': 18}
  
       a__						=parent
       a__						=batch_size
       a__						=num_channels
       a__						=num_frames
       a__						=image_size
       a__						=min_resolution
       a__						=max_resolution
       a__						=do_resize
       a__						=size
       a__						=do_normalize
       a__						=image_mean
       a__						=image_std
       a__						=do_center_crop
       a__						=crop_size
  
  
  
     def 				_UpperCAmelCase				(       self )							->					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,
           "do_center_crop": self.do_center_crop,
           "crop_size": self.crop_size,
       }
  
  
  
  
  
  
  
  @require_torch
  @require_vision
  class 		__magic_name__    (							lowerCamelCase__	, unittest.TestCase							):
  
     '''simple docstring'''
  
  
  
  
     lowerCamelCase__				:			str												=     TvltImageProcessor if is_vision_available() else None
  
  
  
     def 				_UpperCAmelCase				(       self )							->					Optional[Any]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=TvltImageProcessorTester(self )
  
  
  
     @property
     def 				_UpperCAmelCase				(       self )							->					Optional[Any]:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       return self.image_processor_tester.prepare_image_processor_dict()
  
  
  
     def 				_UpperCAmelCase				(       self )							->					str:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=self.image_processing_class(**self.image_processor_dict )
       self.assertTrue(hasattr(lowercase_,					'''image_mean''' ) )
       self.assertTrue(hasattr(lowercase_,					'''image_std''' ) )
       self.assertTrue(hasattr(lowercase_,					'''do_normalize''' ) )
       self.assertTrue(hasattr(lowercase_,					'''do_resize''' ) )
       self.assertTrue(hasattr(lowercase_,					'''do_center_crop''' ) )
       self.assertTrue(hasattr(lowercase_,					'''size''' ) )
  
  
  
     def 				_UpperCAmelCase				(       self )							->					Tuple:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=self.image_processing_class(**self.image_processor_dict )
       # create random PIL videos
       a__						=prepare_video_inputs(self.image_processor_tester,					equal_resolution=lowercase_ )
       for video in video_inputs:
         self.assertIsInstance(lowercase_,					lowercase_ )
         self.assertIsInstance(video[0],					Image.Image )
  
       # Test not batched input
       a__						=image_processor(video_inputs[0],					return_tensors='''pt''' ).pixel_values
       self.assertEqual(
           encoded_videos.shape,					(
               1,
               self.image_processor_tester.num_frames,
               self.image_processor_tester.num_channels,
               self.image_processor_tester.crop_size['''height'''],
               self.image_processor_tester.crop_size['''width'''],
           ),					)
  
       # Test batched
       a__						=image_processor(lowercase_,					return_tensors='''pt''' ).pixel_values
       self.assertEqual(
           encoded_videos.shape,					(
               self.image_processor_tester.batch_size,
               self.image_processor_tester.num_frames,
               self.image_processor_tester.num_channels,
               self.image_processor_tester.crop_size['''height'''],
               self.image_processor_tester.crop_size['''width'''],
           ),					)
  
  
  
     def 				_UpperCAmelCase				(       self )							->					int:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=self.image_processing_class(**self.image_processor_dict )
       # create random numpy tensors
       a__						=prepare_video_inputs(self.image_processor_tester,					equal_resolution=lowercase_,					numpify=lowercase_ )
       for video in video_inputs:
         self.assertIsInstance(lowercase_,					lowercase_ )
         self.assertIsInstance(video[0],					np.ndarray )
  
       # Test not batched input
       a__						=image_processor(video_inputs[0],					return_tensors='''pt''' ).pixel_values
       self.assertEqual(
           encoded_videos.shape,					(
               1,
               self.image_processor_tester.num_frames,
               self.image_processor_tester.num_channels,
               self.image_processor_tester.crop_size['''height'''],
               self.image_processor_tester.crop_size['''width'''],
           ),					)
  
       # Test batched
       a__						=image_processor(lowercase_,					return_tensors='''pt''' ).pixel_values
       self.assertEqual(
           encoded_videos.shape,					(
               self.image_processor_tester.batch_size,
               self.image_processor_tester.num_frames,
               self.image_processor_tester.num_channels,
               self.image_processor_tester.crop_size['''height'''],
               self.image_processor_tester.crop_size['''width'''],
           ),					)
  
  
  
     def 				_UpperCAmelCase				(       self )							->					int:
  
  
  
  
  
  
       """simple docstring"""
  
  
  
  
  
  
       a__						=self.image_processing_class(**self.image_processor_dict )
       # create random PyTorch tensors
       a__						=prepare_video_inputs(self.image_processor_tester,					equal_resolution=lowercase_,					torchify=lowercase_ )
       for video in video_inputs:
         self.assertIsInstance(lowercase_,					lowercase_ )
         self.assertIsInstance(video[0],					torch.Tensor )
  
       # Test not batched input
       a__						=image_processor(video_inputs[0],					return_tensors='''pt''' ).pixel_values
       self.assertEqual(
           encoded_videos.shape,					(
               1,
               self.image_processor_tester.num_frames,
               self.image_processor_tester.num_channels,
               self.image_processor_tester.crop_size['''height'''],
               self.image_processor_tester.crop_size['''width'''],
           ),					)
  
       # Test batched
       a__						=image_processor(lowercase_,					return_tensors='''pt''' ).pixel_values
       self.assertEqual(
           encoded_videos.shape,					(
               self.image_processor_tester.batch_size,
               self.image_processor_tester.num_frames,
               self.image_processor_tester.num_channels,
               self.image_processor_tester.crop_size['''height'''],
               self.image_processor_tester.crop_size['''width'''],
           ),					)
  