






import copy
import unittest

from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

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


if is_torch_available():
     import torch

     from transformers import (
         MODEL_FOR_MULTIPLE_CHOICE_MAPPING,
         MODEL_FOR_QUESTION_ANSWERING_MAPPING,
         MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING,
         MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING,
         LayoutLMvaConfig,
         LayoutLMvaForQuestionAnswering,
         LayoutLMvaForSequenceClassification,
         LayoutLMvaForTokenClassification,
         LayoutLMvaModel,
     )
     from transformers.models.layoutlmva.modeling_layoutlmva import LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST

if is_vision_available():
     from PIL import Image

     from transformers import LayoutLMvaImageProcessor






class 		lowercase_					:






      '''simple docstring'''




      def __init__(      self      :						Tuple ,					__UpperCAmelCase      :						Optional[Any] ,					__UpperCAmelCase      :						Dict=2 ,					__UpperCAmelCase      :						Any=3 ,					__UpperCAmelCase      :						List[Any]=4 ,					__UpperCAmelCase      :						Any=2 ,					__UpperCAmelCase      :						int=7 ,					__UpperCAmelCase      :						Tuple=True ,					__UpperCAmelCase      :						Dict=True ,					__UpperCAmelCase      :						Union[str, Any]=True ,					__UpperCAmelCase      :						Dict=True ,					__UpperCAmelCase      :						Union[str, Any]=99 ,					__UpperCAmelCase      :						Tuple=36 ,					__UpperCAmelCase      :						Optional[Any]=3 ,					__UpperCAmelCase      :						List[str]=4 ,					__UpperCAmelCase      :						Union[str, Any]=37 ,					__UpperCAmelCase      :						Union[str, Any]="gelu" ,					__UpperCAmelCase      :						Any=0.1 ,					__UpperCAmelCase      :						List[str]=0.1 ,					__UpperCAmelCase      :						int=512 ,					__UpperCAmelCase      :						str=16 ,					__UpperCAmelCase      :						Optional[Any]=2 ,					__UpperCAmelCase      :						List[Any]=0.02 ,					__UpperCAmelCase      :						Any=6 ,					__UpperCAmelCase      :						Tuple=6 ,					__UpperCAmelCase      :						Optional[int]=3 ,					__UpperCAmelCase      :						int=4 ,					__UpperCAmelCase      :						str=None ,					__UpperCAmelCase      :						Tuple=1_000 ,					)    ->str:




       """simple docstring"""


       a		  =      parent
       a		  =      batch_size
       a		  =      num_channels
       a		  =      image_size
       a		  =      patch_size
       a		  =      text_seq_length
       a		  =      is_training
       a		  =      use_input_mask
       a		  =      use_token_type_ids
       a		  =      use_labels
       a		  =      vocab_size
       a		  =      hidden_size
       a		  =      num_hidden_layers
       a		  =      num_attention_heads
       a		  =      intermediate_size
       a		  =      hidden_act
       a		  =      hidden_dropout_prob
       a		  =      attention_probs_dropout_prob
       a		  =      max_position_embeddings
       a		  =      type_vocab_size
       a		  =      type_sequence_label_size
       a		  =      initializer_range
       a		  =      coordinate_size
       a		  =      shape_size
       a		  =      num_labels
       a		  =      num_choices
       a		  =      scope
       a		  =      range_bbox

       # LayoutLMv3's sequence length equals the number of text tokens + number of patches + 1 (we add 1 for the CLS token)
       a		  =      text_seq_length
       a		  =      (image_size // patch_size) ** 2 + 1
       a		  =      self.text_seq_length + self.image_seq_length







      def       __lowerCAmelCase					(      self      :						Dict  )    ->Any:




       """simple docstring"""


       a		  =      ids_tensor([self.batch_size, self.text_seq_length] ,					self.vocab_size  )

       a		  =      ids_tensor([self.batch_size, self.text_seq_length, 4] ,					self.range_bbox  )
       # Ensure that bbox is legal
       for i in range(bbox.shape[0]  ):
        for j in range(bbox.shape[1]  ):
         if bbox[i, j, 3] < bbox[i, j, 1]:
          a		  =      bbox[i, j, 3]
          a		  =      bbox[i, j, 1]
          a		  =      t
         if bbox[i, j, 2] < bbox[i, j, 0]:
          a		  =      bbox[i, j, 2]
          a		  =      bbox[i, j, 0]
          a		  =      t

       a		  =      floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]  )

       a		  =      None
       if self.use_input_mask:
        a		  =      random_attention_mask([self.batch_size, self.text_seq_length]  )

       a		  =      None
       if self.use_token_type_ids:
        a		  =      ids_tensor([self.batch_size, self.text_seq_length] ,					self.type_vocab_size  )

       a		  =      None
       a		  =      None
       if self.use_labels:
        a		  =      ids_tensor([self.batch_size] ,					self.type_sequence_label_size  )
        a		  =      ids_tensor([self.batch_size, self.text_seq_length] ,					self.num_labels  )

       a		  =      LayoutLMvaConfig(
           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 ,					coordinate_size=self.coordinate_size ,					shape_size=self.shape_size ,					input_size=self.image_size ,					patch_size=self.patch_size ,					)

       return config, input_ids, bbox, pixel_values, token_type_ids, input_mask, sequence_labels, token_labels







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




       """simple docstring"""


       a		  =      LayoutLMvaModel(config=__UpperCAmelCase  )
       model.to(__UpperCAmelCase  )
       model.eval()

       # text + image
       a		  =      model(__UpperCAmelCase ,					pixel_values=__UpperCAmelCase  )
       a		  =      model(
           __UpperCAmelCase ,					bbox=__UpperCAmelCase ,					pixel_values=__UpperCAmelCase ,					attention_mask=__UpperCAmelCase ,					token_type_ids=__UpperCAmelCase  )
       a		  =      model(__UpperCAmelCase ,					bbox=__UpperCAmelCase ,					pixel_values=__UpperCAmelCase ,					token_type_ids=__UpperCAmelCase  )
       a		  =      model(__UpperCAmelCase ,					bbox=__UpperCAmelCase ,					pixel_values=__UpperCAmelCase  )

       self.parent.assertEqual(result.last_hidden_state.shape ,					(self.batch_size, self.seq_length, self.hidden_size)  )

       # text only
       a		  =      model(__UpperCAmelCase  )
       self.parent.assertEqual(
           result.last_hidden_state.shape ,					(self.batch_size, self.text_seq_length, self.hidden_size)  )

       # image only
       a		  =      model(pixel_values=__UpperCAmelCase  )
       self.parent.assertEqual(
           result.last_hidden_state.shape ,					(self.batch_size, self.image_seq_length, self.hidden_size)  )







      def       __lowerCAmelCase					(      self      :						List[Any] ,					__UpperCAmelCase      :						str ,					__UpperCAmelCase      :						Optional[int] ,					__UpperCAmelCase      :						int ,					__UpperCAmelCase      :						Optional[Any] ,					__UpperCAmelCase      :						Tuple ,					__UpperCAmelCase      :						int ,					__UpperCAmelCase      :						List[Any] ,					__UpperCAmelCase      :						Tuple  )    ->List[str]:




       """simple docstring"""


       a		  =      self.num_labels
       a		  =      LayoutLMvaForSequenceClassification(__UpperCAmelCase  )
       model.to(__UpperCAmelCase  )
       model.eval()
       a		  =      model(
           __UpperCAmelCase ,					bbox=__UpperCAmelCase ,					pixel_values=__UpperCAmelCase ,					attention_mask=__UpperCAmelCase ,					token_type_ids=__UpperCAmelCase ,					labels=__UpperCAmelCase ,					)
       self.parent.assertEqual(result.logits.shape ,					(self.batch_size, self.num_labels)  )







      def       __lowerCAmelCase					(      self      :						Dict ,					__UpperCAmelCase      :						str ,					__UpperCAmelCase      :						Optional[int] ,					__UpperCAmelCase      :						str ,					__UpperCAmelCase      :						int ,					__UpperCAmelCase      :						Any ,					__UpperCAmelCase      :						int ,					__UpperCAmelCase      :						Optional[Any] ,					__UpperCAmelCase      :						Any  )    ->int:




       """simple docstring"""


       a		  =      self.num_labels
       a		  =      LayoutLMvaForTokenClassification(config=__UpperCAmelCase  )
       model.to(__UpperCAmelCase  )
       model.eval()
       a		  =      model(
           __UpperCAmelCase ,					bbox=__UpperCAmelCase ,					pixel_values=__UpperCAmelCase ,					attention_mask=__UpperCAmelCase ,					token_type_ids=__UpperCAmelCase ,					labels=__UpperCAmelCase ,					)
       self.parent.assertEqual(result.logits.shape ,					(self.batch_size, self.text_seq_length, self.num_labels)  )







      def       __lowerCAmelCase					(      self      :						str ,					__UpperCAmelCase      :						Tuple ,					__UpperCAmelCase      :						str ,					__UpperCAmelCase      :						Optional[Any] ,					__UpperCAmelCase      :						str ,					__UpperCAmelCase      :						List[str] ,					__UpperCAmelCase      :						Union[str, Any] ,					__UpperCAmelCase      :						List[str] ,					__UpperCAmelCase      :						Union[str, Any]  )    ->str:




       """simple docstring"""


       a		  =      LayoutLMvaForQuestionAnswering(config=__UpperCAmelCase  )
       model.to(__UpperCAmelCase  )
       model.eval()
       a		  =      model(
           __UpperCAmelCase ,					bbox=__UpperCAmelCase ,					pixel_values=__UpperCAmelCase ,					attention_mask=__UpperCAmelCase ,					token_type_ids=__UpperCAmelCase ,					start_positions=__UpperCAmelCase ,					end_positions=__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       __lowerCAmelCase					(      self      :						int  )    ->Optional[int]:




       """simple docstring"""


       a		  =      self.prepare_config_and_inputs()
       (
           (
           a
       )  ,     (
           a
       )  ,     (
           a
       )  ,     (
           a
       )  ,     (
           a
       )  ,     (
           a
       )  ,     (
           a
       )  ,     (
           a
       )  ,     
       )		  =      config_and_inputs
       a		  =      {
           '''input_ids''': input_ids,
           '''bbox''': bbox,
           '''pixel_values''': pixel_values,
           '''token_type_ids''': token_type_ids,
           '''attention_mask''': input_mask,
       }
       return config, inputs_dict






@require_torch
class 		lowercase_					(	lowercase ,  lowercase ,  unittest.TestCase   ):






      '''simple docstring'''




      __snake_case       =  False
      __snake_case       =  False
      __snake_case       =  False

      __snake_case       =  (
          (
              LayoutLMvaModel,
              LayoutLMvaForSequenceClassification,
              LayoutLMvaForTokenClassification,
              LayoutLMvaForQuestionAnswering,
          )
          if is_torch_available()
          else ()
      )
      __snake_case       =  (
          {'''document-question-answering''': LayoutLMvaForQuestionAnswering, '''feature-extraction''': LayoutLMvaModel}
          if is_torch_available()
          else {}
      )







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




       """simple docstring"""


       return True







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




       """simple docstring"""


       a		  =      LayoutLMvaModelTester(self  )
       a		  =      ConfigTester(self ,					config_class=__UpperCAmelCase ,					hidden_size=37  )







      def       __lowerCAmelCase					(      self      :						Optional[int] ,					__UpperCAmelCase      :						Dict ,					__UpperCAmelCase      :						int ,					__UpperCAmelCase      :						str=False  )    ->Optional[int]:




       """simple docstring"""


       a		  =      copy.deepcopy(__UpperCAmelCase  )
       if model_class in get_values(__UpperCAmelCase  ):
        a		  =      {
            k: v.unsqueeze(1  ).expand(-1 ,					self.model_tester.num_choices ,					-1  ).contiguous()
            if isinstance(__UpperCAmelCase ,					torch.Tensor  ) and v.ndim > 1
            else v
            for k, v in inputs_dict.items()
        }
       if return_labels:
        if model_class in get_values(__UpperCAmelCase  ):
         a		  =      torch.ones(self.model_tester.batch_size ,					dtype=torch.long ,					device=__UpperCAmelCase  )
        elif model_class in get_values(__UpperCAmelCase  ):
         a		  =      torch.zeros(
             self.model_tester.batch_size ,					dtype=torch.long ,					device=__UpperCAmelCase  )
         a		  =      torch.zeros(
             self.model_tester.batch_size ,					dtype=torch.long ,					device=__UpperCAmelCase  )
        elif model_class in [
            *get_values(__UpperCAmelCase  ),
        ]:
         a		  =      torch.zeros(
             self.model_tester.batch_size ,					dtype=torch.long ,					device=__UpperCAmelCase  )
        elif model_class in [
            *get_values(__UpperCAmelCase  ),
        ]:
         a		  =      torch.zeros(
             (self.model_tester.batch_size, self.model_tester.text_seq_length) ,					dtype=torch.long ,					device=__UpperCAmelCase ,					)

       return inputs_dict







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




       """simple docstring"""


       self.config_tester.run_common_tests()







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




       """simple docstring"""


       a		  =      self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_model(*__UpperCAmelCase  )







      def       __lowerCAmelCase					(      self      :						Tuple  )    ->List[str]:




       """simple docstring"""


       a		  =      self.model_tester.prepare_config_and_inputs()
       for type in ["absolute", "relative_key", "relative_key_query"]:
        a		  =      type
        self.model_tester.create_and_check_model(*__UpperCAmelCase  )







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




       """simple docstring"""


       a		  =      self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_sequence_classification(*__UpperCAmelCase  )







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




       """simple docstring"""


       a		  =      self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_token_classification(*__UpperCAmelCase  )







      def       __lowerCAmelCase					(      self      :						int  )    ->List[Any]:




       """simple docstring"""


       a		  =      self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_question_answering(*__UpperCAmelCase  )







      @slow
      def       __lowerCAmelCase					(      self      :						Optional[int]  )    ->List[Any]:




       """simple docstring"""


       for model_name in LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
        a		  =      LayoutLMvaModel.from_pretrained(__UpperCAmelCase  )
        self.assertIsNotNone(__UpperCAmelCase  )
def 						_a    (      )							->			List[Any]:
 a		  =      Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png''' )
 return image






@require_torch
class 		lowercase_					(	unittest.TestCase   ):






      '''simple docstring'''




      @cached_property
      def       __lowerCAmelCase					(      self      :						Union[str, Any]  )    ->Union[str, Any]:




       """simple docstring"""


       return LayoutLMvaImageProcessor(apply_ocr=__UpperCAmelCase  ) if is_vision_available() else None







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




       """simple docstring"""


       a		  =      LayoutLMvaModel.from_pretrained('''microsoft/layoutlmv3-base'''  ).to(__UpperCAmelCase  )

       a		  =      self.default_image_processor
       a		  =      prepare_img()
       a		  =      image_processor(images=__UpperCAmelCase ,					return_tensors='''pt'''  ).pixel_values.to(__UpperCAmelCase  )

       a		  =      torch.tensor([[1, 2]]  )
       a		  =      torch.tensor([[1, 2, 3, 4], [5, 6, 7, 8]]  ).unsqueeze(0  )

       # forward pass
       a		  =      model(
           input_ids=input_ids.to(__UpperCAmelCase  ) ,					bbox=bbox.to(__UpperCAmelCase  ) ,					pixel_values=pixel_values.to(__UpperCAmelCase  ) ,					)

       # verify the logits
       a		  =      torch.Size((1, 199, 768)  )
       self.assertEqual(outputs.last_hidden_state.shape ,					__UpperCAmelCase  )

       a		  =      torch.tensor(
           [[-0.0529, 0.3618, 0.1632], [-0.1587, -0.1667, -0.0400], [-0.1557, -0.1671, -0.0505]]  ).to(__UpperCAmelCase  )

       self.assertTrue(torch.allclose(outputs.last_hidden_state[0, :3, :3] ,					__UpperCAmelCase ,					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_video_inputs


if is_torch_available():
						import torch

if is_vision_available():
						from PIL import Image

						from transformers import VivitImageProcessor
class        _lowercase      (			unittest.TestCase       ):






				'''simple docstring'''



				def __init__(       self			:Any			,			lowerCAmelCase__			:Union[str, Any]			,			lowerCAmelCase__			:Tuple=7			,			lowerCAmelCase__			:List[Any]=3			,			lowerCAmelCase__			:Any=10			,			lowerCAmelCase__			:Optional[int]=18			,			lowerCAmelCase__			:Dict=30			,			lowerCAmelCase__			:Tuple=400			,			lowerCAmelCase__			:List[Any]=True			,			lowerCAmelCase__			:Tuple=None			,			lowerCAmelCase__			:str=True			,			lowerCAmelCase__			:List[str]=[0.5, 0.5, 0.5]			,			lowerCAmelCase__			:List[str]=[0.5, 0.5, 0.5]			,			lowerCAmelCase__			:Optional[Any]=None			,			)		->			Optional[Any]:
										__SCREAMING_SNAKE_CASE						:     Dict					=		size if size is not None else {'''shortest_edge''': 18}
										__SCREAMING_SNAKE_CASE						:     Optional[int]					=		crop_size if crop_size is not None else {'''height''': 18, '''width''': 18}

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



				def 		__magic_name__(       self			:Tuple	)		->			Any:
										return {
										    "image_mean": self.image_mean,
										    "image_std": self.image_std,
										    "do_normalize": self.do_normalize,
										    "do_resize": self.do_resize,
										    "size": self.size,
										    "crop_size": self.crop_size,
										}




@require_torch
@require_vision
class        _lowercase      (			A__						,			unittest.TestCase       ):






				'''simple docstring'''



				SCREAMING_SNAKE_CASE__				:			List[str]						=		VivitImageProcessor if is_vision_available() else None


				def 		__magic_name__(       self			:List[str]	)		->			Union[str, Any]:
										__SCREAMING_SNAKE_CASE						:     str					=		VivitImageProcessingTester(self	)


				@property
				def 		__magic_name__(       self			:int	)		->			Union[str, Any]:
										return self.image_processor_tester.prepare_image_processor_dict()


				def 		__magic_name__(       self			:List[str]	)		->			Optional[int]:
										__SCREAMING_SNAKE_CASE						:     Optional[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__			,			'''do_center_crop'''	)	)
										self.assertTrue(hasattr(lowerCAmelCase__			,			'''size'''	)	)


				def 		__magic_name__(       self			:Optional[Any]	)		->			Optional[int]:
										__SCREAMING_SNAKE_CASE						:     Union[str, Any]					=		self.image_processing_class.from_dict(self.image_processor_dict	)
										self.assertEqual(image_processor.size			,			{'''shortest_edge''': 18}	)
										self.assertEqual(image_processor.crop_size			,			{'''height''': 18, '''width''': 18}	)

										__SCREAMING_SNAKE_CASE						:     Tuple					=		self.image_processing_class.from_dict(self.image_processor_dict			,			size=42			,			crop_size=84	)
										self.assertEqual(image_processor.size			,			{'''shortest_edge''': 42}	)
										self.assertEqual(image_processor.crop_size			,			{'''height''': 84, '''width''': 84}	)


				def 		__magic_name__(       self			:List[Any]	)		->			Union[str, Any]:
										# Initialize image_processing
										__SCREAMING_SNAKE_CASE						:     Dict					=		self.image_processing_class(**self.image_processor_dict	)
										# create random PIL videos
										__SCREAMING_SNAKE_CASE						:     List[Any]					=		prepare_video_inputs(self.image_processor_tester			,			equal_resolution=lowerCAmelCase__	)
										for video in video_inputs:
																self.assertIsInstance(lowerCAmelCase__			,			lowerCAmelCase__	)
																self.assertIsInstance(video[0]			,			Image.Image	)

										# Test not batched input
										__SCREAMING_SNAKE_CASE						:     List[str]					=		image_processing(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
										__SCREAMING_SNAKE_CASE						:     Optional[Any]					=		image_processing(lowerCAmelCase__			,			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 		__magic_name__(       self			:str	)		->			int:
										# Initialize image_processing
										__SCREAMING_SNAKE_CASE						:     Any					=		self.image_processing_class(**self.image_processor_dict	)
										# create random numpy tensors
										__SCREAMING_SNAKE_CASE						:     List[str]					=		prepare_video_inputs(self.image_processor_tester			,			equal_resolution=lowerCAmelCase__			,			numpify=lowerCAmelCase__	)
										for video in video_inputs:
																self.assertIsInstance(lowerCAmelCase__			,			lowerCAmelCase__	)
																self.assertIsInstance(video[0]			,			np.ndarray	)

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

										# Test not batched input
										__SCREAMING_SNAKE_CASE						:     Tuple					=		image_processing(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
										__SCREAMING_SNAKE_CASE						:     Optional[int]					=		image_processing(lowerCAmelCase__			,			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'''],
										    )			,			)
