"""simple docstring"""






import inspect
import unittest

from transformers import DPTConfig
from transformers.file_utils import is_torch_available, is_vision_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, require_vision, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
       import torch
       from torch import nn

       from transformers import MODEL_MAPPING, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTModel
       from transformers.models.dpt.modeling_dpt import DPT_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
       from PIL import Image

       from transformers import DPTImageProcessor


class 					UpperCAmelCase		:



    """simple docstring"""

    def __init__(     self					,    _UpperCAmelCase					,    _UpperCAmelCase=2					,    _UpperCAmelCase=32					,    _UpperCAmelCase=16					,    _UpperCAmelCase=3					,    _UpperCAmelCase=True					,    _UpperCAmelCase=True					,    _UpperCAmelCase=32					,    _UpperCAmelCase=4					,    _UpperCAmelCase=[0, 1, 2, 3]					,    _UpperCAmelCase=4					,    _UpperCAmelCase=37					,    _UpperCAmelCase="gelu"					,    _UpperCAmelCase=0.1					,    _UpperCAmelCase=0.1					,    _UpperCAmelCase=0.02					,    _UpperCAmelCase=3					,    _UpperCAmelCase=False					,    _UpperCAmelCase=None					,    ):
       lowercase__:     str      =   parent
       lowercase__:     List[Any]      =   batch_size
       lowercase__:     List[Any]      =   image_size
       lowercase__:     Dict      =   patch_size
       lowercase__:     Union[str, Any]      =   num_channels
       lowercase__:     Union[str, Any]      =   is_training
       lowercase__:     Any      =   use_labels
       lowercase__:     str      =   hidden_size
       lowercase__:     Tuple      =   num_hidden_layers
       lowercase__:     Tuple      =   backbone_out_indices
       lowercase__:     List[str]      =   num_attention_heads
       lowercase__:     Dict      =   intermediate_size
       lowercase__:     str      =   hidden_act
       lowercase__:     List[str]      =   hidden_dropout_prob
       lowercase__:     Optional[int]      =   attention_probs_dropout_prob
       lowercase__:     str      =   initializer_range
       lowercase__:     List[str]      =   num_labels
       lowercase__:     Union[str, Any]      =   scope
       lowercase__:     List[str]      =   is_hybrid
       # sequence length of DPT = num_patches + 1 (we add 1 for the [CLS] token)
       lowercase__:     int      =   (image_size // patch_size) ** 2
       lowercase__:     Union[str, Any]      =   num_patches + 1






    def _snake_case    (     self							):
       lowercase__:     List[Any]      =   floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]							)

       lowercase__:     Any      =   None
       if self.use_labels:
          lowercase__:     List[str]      =   ids_tensor([self.batch_size, self.image_size, self.image_size]					,    self.num_labels							)

       lowercase__:     str      =   self.get_config()

       return config, pixel_values, labels






    def _snake_case    (     self							):
       return DPTConfig(
           image_size=self.image_size					,    patch_size=self.patch_size					,    num_channels=self.num_channels					,    hidden_size=self.hidden_size					,    num_hidden_layers=self.num_hidden_layers					,    backbone_out_indices=self.backbone_out_indices					,    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					,    is_decoder=_UpperCAmelCase					,    initializer_range=self.initializer_range					,    is_hybrid=self.is_hybrid					,    )






    def _snake_case    (     self					,    _UpperCAmelCase					,    _UpperCAmelCase					,    _UpperCAmelCase							):
       lowercase__:     str      =   DPTModel(config=_UpperCAmelCase							)
       model.to(_UpperCAmelCase							)
       model.eval()
       lowercase__:     Optional[Any]      =   model(_UpperCAmelCase							)
       self.parent.assertEqual(result.last_hidden_state.shape					,    (self.batch_size, self.seq_length, self.hidden_size)							)






    def _snake_case    (     self					,    _UpperCAmelCase					,    _UpperCAmelCase					,    _UpperCAmelCase							):
       lowercase__:     Tuple      =   self.num_labels
       lowercase__:     List[Any]      =   DPTForDepthEstimation(_UpperCAmelCase							)
       model.to(_UpperCAmelCase							)
       model.eval()
       lowercase__:     Dict      =   model(_UpperCAmelCase							)
       self.parent.assertEqual(result.predicted_depth.shape					,    (self.batch_size, self.image_size, self.image_size)							)






    def _snake_case    (     self					,    _UpperCAmelCase					,    _UpperCAmelCase					,    _UpperCAmelCase							):
       lowercase__:     List[Any]      =   self.num_labels
       lowercase__:     Tuple      =   DPTForSemanticSegmentation(_UpperCAmelCase							)
       model.to(_UpperCAmelCase							)
       model.eval()
       lowercase__:     Optional[int]      =   model(_UpperCAmelCase					,    labels=_UpperCAmelCase							)
       self.parent.assertEqual(
           result.logits.shape					,    (self.batch_size, self.num_labels, self.image_size, self.image_size)							)






    def _snake_case    (     self							):
       lowercase__:     Union[str, Any]      =   self.prepare_config_and_inputs()
       lowercase__,				lowercase__,				lowercase__:     str      =   config_and_inputs
       lowercase__:     Tuple      =   {'''pixel_values''': pixel_values}
       return config, inputs_dict



@require_torch
class 					UpperCAmelCase		(_UpperCAmelCase					,_UpperCAmelCase					,unittest.TestCase						):



    """simple docstring"""

    _UpperCAmelCase			:Dict							=				(DPTModel, DPTForDepthEstimation, DPTForSemanticSegmentation) if is_torch_available() else ()
    _UpperCAmelCase			:List[str]							=				(
        {
            "depth-estimation": DPTForDepthEstimation,
            "feature-extraction": DPTModel,
            "image-segmentation": DPTForSemanticSegmentation,
        }
        if is_torch_available()
        else {}
    )

    _UpperCAmelCase			:Tuple							=				False
    _UpperCAmelCase			:Union[str, Any]							=				False
    _UpperCAmelCase			:Dict							=				False






    def _snake_case    (     self							):
       lowercase__:     Optional[int]      =   DPTModelTester(self							)
       lowercase__:     Dict      =   ConfigTester(self					,    config_class=_UpperCAmelCase					,    has_text_modality=_UpperCAmelCase					,    hidden_size=37							)






    def _snake_case    (     self							):
       self.config_tester.run_common_tests()






    @unittest.skip(reason='''DPT does not use inputs_embeds'''							)
    def _snake_case    (     self							):
       pass






    def _snake_case    (     self							):
       lowercase__,				lowercase__:     Dict      =   self.model_tester.prepare_config_and_inputs_for_common()

       for model_class in self.all_model_classes:
          lowercase__:     Dict      =   model_class(_UpperCAmelCase							)
          self.assertIsInstance(model.get_input_embeddings()					,    (nn.Module)							)
          lowercase__:     List[Any]      =   model.get_output_embeddings()
          self.assertTrue(x is None or isinstance(_UpperCAmelCase					,    nn.Linear							)							)






    def _snake_case    (     self							):
       lowercase__,				lowercase__:     Optional[Any]      =   self.model_tester.prepare_config_and_inputs_for_common()

       for model_class in self.all_model_classes:
          lowercase__:     Dict      =   model_class(_UpperCAmelCase							)
          lowercase__:     int      =   inspect.signature(model.forward							)
          # signature.parameters is an OrderedDict => so arg_names order is deterministic
          lowercase__:     str      =   [*signature.parameters.keys()]

          lowercase__:     Tuple      =   ['''pixel_values''']
          self.assertListEqual(arg_names[:1]					,    _UpperCAmelCase							)






    def _snake_case    (     self							):
       lowercase__:     Optional[int]      =   self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_model(*_UpperCAmelCase							)






    def _snake_case    (     self							):
       lowercase__:     Optional[int]      =   self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_depth_estimation(*_UpperCAmelCase							)






    def _snake_case    (     self							):
       lowercase__:     List[str]      =   self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_semantic_segmentation(*_UpperCAmelCase							)






    def _snake_case    (     self							):
       for model_class in self.all_model_classes:
          if model_class.__name__ == "DPTForDepthEstimation":
             continue

          lowercase__,				lowercase__:     Dict      =   self.model_tester.prepare_config_and_inputs_for_common()
          lowercase__:     int      =   True

          if model_class in get_values(_UpperCAmelCase							):
             continue

          lowercase__:     List[Any]      =   model_class(_UpperCAmelCase							)
          model.to(_UpperCAmelCase							)
          model.train()
          lowercase__:     Dict      =   self._prepare_for_class(_UpperCAmelCase					,    _UpperCAmelCase					,    return_labels=_UpperCAmelCase							)
          lowercase__:     int      =   model(**_UpperCAmelCase							).loss
          loss.backward()






    def _snake_case    (     self							):
       for model_class in self.all_model_classes:
          if model_class.__name__ == "DPTForDepthEstimation":
             continue

          lowercase__,				lowercase__:     Optional[Any]      =   self.model_tester.prepare_config_and_inputs_for_common()
          lowercase__:     Union[str, Any]      =   False
          lowercase__:     Optional[int]      =   True

          if model_class in get_values(_UpperCAmelCase							) or not model_class.supports_gradient_checkpointing:
             continue
          lowercase__:     Optional[Any]      =   model_class(_UpperCAmelCase							)
          model.to(_UpperCAmelCase							)
          model.gradient_checkpointing_enable()
          model.train()
          lowercase__:     Union[str, Any]      =   self._prepare_for_class(_UpperCAmelCase					,    _UpperCAmelCase					,    return_labels=_UpperCAmelCase							)
          lowercase__:     Union[str, Any]      =   model(**_UpperCAmelCase							).loss
          loss.backward()






    def _snake_case    (     self							):
       lowercase__,				lowercase__:     Optional[Any]      =   self.model_tester.prepare_config_and_inputs_for_common()

       lowercase__:     Tuple      =   _config_zero_init(_UpperCAmelCase							)
       for model_class in self.all_model_classes:
          lowercase__:     Any      =   model_class(config=_UpperCAmelCase							)
          # Skip the check for the backbone
          lowercase__:     List[Any]      =   []
          for name, module in model.named_modules():
             if module.__class__.__name__ == "DPTViTHybridEmbeddings":
                lowercase__:     Optional[Any]      =   [F"""{name}.{key}""" for key in module.state_dict().keys()]
                break

          for name, param in model.named_parameters():
             if param.requires_grad:
                if name in backbone_params:
                   continue
                self.assertIn(
                    ((param.data.mean() * 1e9).round() / 1e9).item()					,    [0.0, 1.0]					,    msg=F"""Parameter {name} of model {model_class} seems not properly initialized"""					,    )






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






    @slow
    def _snake_case    (     self							):
       for model_name in DPT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
          lowercase__:     Union[str, Any]      =   DPTModel.from_pretrained(_UpperCAmelCase							)
          self.assertIsNotNone(_UpperCAmelCase							)



def SCREAMING_SNAKE_CASE__    (     )						->						Union[str, Any]:
   lowercase__:     List[Any]      =   Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''				)
   return image




@require_torch
@require_vision
@slow
class 					UpperCAmelCase		(unittest.TestCase						):



    """simple docstring"""

    def _snake_case    (     self							):
       lowercase__:     Any      =   DPTImageProcessor.from_pretrained('''Intel/dpt-large'''							)
       lowercase__:     Any      =   DPTForDepthEstimation.from_pretrained('''Intel/dpt-large'''							).to(_UpperCAmelCase							)

       lowercase__:     List[str]      =   prepare_img()
       lowercase__:     Union[str, Any]      =   image_processor(images=_UpperCAmelCase					,    return_tensors='''pt'''							).to(_UpperCAmelCase							)

       # forward pass
       with torch.no_grad():
          lowercase__:     Optional[int]      =   model(**_UpperCAmelCase							)
          lowercase__:     Tuple      =   outputs.predicted_depth

       # verify the predicted depth
       lowercase__:     Any      =   torch.Size((1, 384, 384)							)
       self.assertEqual(predicted_depth.shape					,    _UpperCAmelCase							)

       lowercase__:     List[Any]      =   torch.tensor(
           [[6.3_199, 6.3_629, 6.4_148], [6.3_850, 6.3_615, 6.4_166], [6.3_519, 6.3_176, 6.3_575]]							).to(_UpperCAmelCase							)

       self.assertTrue(torch.allclose(outputs.predicted_depth[0, :3, :3]					,    _UpperCAmelCase					,    atol=1e-4							)							)






    def _snake_case    (     self							):
       lowercase__:     Optional[int]      =   DPTImageProcessor.from_pretrained('''Intel/dpt-large-ade'''							)
       lowercase__:     Tuple      =   DPTForSemanticSegmentation.from_pretrained('''Intel/dpt-large-ade'''							).to(_UpperCAmelCase							)

       lowercase__:     Optional[Any]      =   prepare_img()
       lowercase__:     List[Any]      =   image_processor(images=_UpperCAmelCase					,    return_tensors='''pt'''							).to(_UpperCAmelCase							)

       # forward pass
       with torch.no_grad():
          lowercase__:     Optional[Any]      =   model(**_UpperCAmelCase							)

       # verify the logits
       lowercase__:     Union[str, Any]      =   torch.Size((1, 150, 480, 480)							)
       self.assertEqual(outputs.logits.shape					,    _UpperCAmelCase							)

       lowercase__:     List[Any]      =   torch.tensor(
           [[4.0_480, 4.2_420, 4.4_360], [4.3_124, 4.5_693, 4.8_261], [4.5_768, 4.8_965, 5.2_163]]							).to(_UpperCAmelCase							)

       self.assertTrue(torch.allclose(outputs.logits[0, 0, :3, :3]					,    _UpperCAmelCase					,    atol=1e-4							)							)






    def _snake_case    (     self							):
       lowercase__:     List[str]      =   DPTImageProcessor.from_pretrained('''Intel/dpt-large-ade'''							)
       lowercase__:     List[str]      =   DPTForSemanticSegmentation.from_pretrained('''Intel/dpt-large-ade'''							).to(_UpperCAmelCase							)

       lowercase__:     Any      =   prepare_img()
       lowercase__:     Optional[int]      =   image_processor(images=_UpperCAmelCase					,    return_tensors='''pt'''							).to(_UpperCAmelCase							)

       # forward pass
       with torch.no_grad():
          lowercase__:     Dict      =   model(**_UpperCAmelCase							)

       lowercase__:     Union[str, Any]      =   outputs.logits.detach().cpu()

       lowercase__:     Optional[int]      =   image_processor.post_process_semantic_segmentation(outputs=_UpperCAmelCase					,    target_sizes=[(500, 300)]							)
       lowercase__:     int      =   torch.Size((500, 300)							)
       self.assertEqual(segmentation[0].shape					,    _UpperCAmelCase							)

       lowercase__:     int      =   image_processor.post_process_semantic_segmentation(outputs=_UpperCAmelCase							)
       lowercase__:     List[str]      =   torch.Size((480, 480)							)
       self.assertEqual(segmentation[0].shape					,    _UpperCAmelCase							)

"""simple docstring"""






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 SCREAMING_SNAKE_CASE__    (     __UpperCAmelCase ,					__UpperCAmelCase=1_0 ,					__UpperCAmelCase=1_0 ,					__UpperCAmelCase=False ,					__UpperCAmelCase=False				)						->						List[str]:
   lowercase__:     List[Any]      =   []
   for i in range(image_processor_tester.num_frames				):
      video.append(np.random.randint(2_5_5 ,					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
      lowercase__:     Union[str, Any]      =   [Image.fromarray(np.moveaxis(__UpperCAmelCase ,					0 ,					-1				)				) for frame in video]

   if torchify:
      lowercase__:     List[str]      =   [torch.from_numpy(__UpperCAmelCase				) for frame in video]

   return video



def SCREAMING_SNAKE_CASE__    (     __UpperCAmelCase ,					__UpperCAmelCase=False ,					__UpperCAmelCase=False ,					__UpperCAmelCase=False				)						->						Tuple:
   assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

   lowercase__:     int      =   []
   for i in range(image_processor_tester.batch_size				):
      if equal_resolution:
         lowercase__:     Any      =   image_processor_tester.max_resolution
      else:
         lowercase__,				lowercase__:     Union[str, Any]      =   np.random.choice(
             np.arange(image_processor_tester.min_resolution ,					image_processor_tester.max_resolution				) ,					2				)
         lowercase__:     str      =   prepare_video(
             image_processor_tester=__UpperCAmelCase ,					width=__UpperCAmelCase ,					height=__UpperCAmelCase ,					numpify=__UpperCAmelCase ,					torchify=__UpperCAmelCase ,					)
      video_inputs.append(__UpperCAmelCase				)

   return video_inputs


class 					UpperCAmelCase		(unittest.TestCase						):



    """simple docstring"""

    def __init__(     self					,    _UpperCAmelCase					,    _UpperCAmelCase=7					,    _UpperCAmelCase=3					,    _UpperCAmelCase=4					,    _UpperCAmelCase=18					,    _UpperCAmelCase=30					,    _UpperCAmelCase=400					,    _UpperCAmelCase=True					,    _UpperCAmelCase=None					,    _UpperCAmelCase=True					,    _UpperCAmelCase=[0.5, 0.5, 0.5]					,    _UpperCAmelCase=[0.5, 0.5, 0.5]					,    _UpperCAmelCase=True					,    _UpperCAmelCase=None					,    ):
       lowercase__:     Any      =   size if size is not None else {'''shortest_edge''': 18}
       lowercase__:     List[Any]      =   crop_size if crop_size is not None else {'''height''': 18, '''width''': 18}

       lowercase__:     List[Any]      =   parent
       lowercase__:     List[str]      =   batch_size
       lowercase__:     Union[str, Any]      =   num_channels
       lowercase__:     List[Any]      =   num_frames
       lowercase__:     Tuple      =   image_size
       lowercase__:     List[Any]      =   min_resolution
       lowercase__:     Union[str, Any]      =   max_resolution
       lowercase__:     Dict      =   do_resize
       lowercase__:     List[Any]      =   size
       lowercase__:     str      =   do_normalize
       lowercase__:     int      =   image_mean
       lowercase__:     Any      =   image_std
       lowercase__:     List[Any]      =   do_center_crop
       lowercase__:     Optional[int]      =   crop_size






    def _snake_case    (     self							):
       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 					UpperCAmelCase		(_UpperCAmelCase					,unittest.TestCase						):



    """simple docstring"""

    _UpperCAmelCase			:str							=				TvltImageProcessor if is_vision_available() else None






    def _snake_case    (     self							):
       lowercase__:     List[Any]      =   TvltImageProcessorTester(self							)






    @property
    def _snake_case    (     self							):
       return self.image_processor_tester.prepare_image_processor_dict()






    def _snake_case    (     self							):
       lowercase__:     List[str]      =   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					,    '''do_center_crop'''							)							)
       self.assertTrue(hasattr(_UpperCAmelCase					,    '''size'''							)							)






    def _snake_case    (     self							):
       # Initialize image_processor
       lowercase__:     List[str]      =   self.image_processing_class(**self.image_processor_dict							)
       # create random PIL videos
       lowercase__:     str      =   prepare_video_inputs(self.image_processor_tester					,    equal_resolution=_UpperCAmelCase							)
       for video in video_inputs:
          self.assertIsInstance(_UpperCAmelCase					,    _UpperCAmelCase							)
          self.assertIsInstance(video[0]					,    Image.Image							)

       # Test not batched input
       lowercase__:     Union[str, Any]      =   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
       lowercase__:     Tuple      =   image_processor(_UpperCAmelCase					,    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 _snake_case    (     self							):
       # Initialize image_processor
       lowercase__:     str      =   self.image_processing_class(**self.image_processor_dict							)
       # create random numpy tensors
       lowercase__:     List[str]      =   prepare_video_inputs(self.image_processor_tester					,    equal_resolution=_UpperCAmelCase					,    numpify=_UpperCAmelCase							)
       for video in video_inputs:
          self.assertIsInstance(_UpperCAmelCase					,    _UpperCAmelCase							)
          self.assertIsInstance(video[0]					,    np.ndarray							)

       # Test not batched input
       lowercase__:     Optional[Any]      =   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
       lowercase__:     Tuple      =   image_processor(_UpperCAmelCase					,    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 _snake_case    (     self							):
       # Initialize image_processor
       lowercase__:     List[Any]      =   self.image_processing_class(**self.image_processor_dict							)
       # create random PyTorch tensors
       lowercase__:     Optional[int]      =   prepare_video_inputs(self.image_processor_tester					,    equal_resolution=_UpperCAmelCase					,    torchify=_UpperCAmelCase							)
       for video in video_inputs:
          self.assertIsInstance(_UpperCAmelCase					,    _UpperCAmelCase							)
          self.assertIsInstance(video[0]					,    torch.Tensor							)

       # Test not batched input
       lowercase__:     Optional[Any]      =   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
       lowercase__:     List[Any]      =   image_processor(_UpperCAmelCase					,    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'''],
           )					,    )
