
import unittest

import numpy as np
import timeout_decorator  # noqa

from transformers import OPTConfig, is_flax_available
from transformers.testing_utils import require_flax, require_sentencepiece, slow

from ...generation.test_flax_utils import FlaxGenerationTesterMixin
from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor


if is_flax_available():
  import os

  # The slow tests are often failing with OOM error on GPU
  # This makes JAX allocate exactly what is needed on demand, and deallocate memory that is no longer needed
  # but will be slower as stated here https://jax.readthedocs.io/en/latest/gpu_memory_allocation.html
  lowercase						:      List[str]							=							"""platform"""

  import jax
  import jax.numpy as jnp

  from transformers import FlaxOPTForCausalLM, FlaxOPTModel, GPTaTokenizer







def 		_snake_case(						SCREAMING_SNAKE_CASE__      ,			SCREAMING_SNAKE_CASE__      ,			SCREAMING_SNAKE_CASE__=None      ,			SCREAMING_SNAKE_CASE__=None       )				->					Any:
       if attention_mask is None:
              lowercase							:  Optional[Any] 			=   np.where(input_ids != config.pad_token_id      ,			1      ,			0       )
       return {
           "input_ids": input_ids,
           "attention_mask": attention_mask,
       }

@require_flax
class __snake_case	:
    def __init__(						self	,snake_case	,snake_case=13	,snake_case=7	,snake_case=True	,snake_case=False	,snake_case=99	,snake_case=16	,snake_case=2	,snake_case=4	,snake_case=4	,snake_case="gelu"	,snake_case=0.1	,snake_case=0.1	,snake_case=20	,snake_case=2	,snake_case=1	,snake_case=0	,snake_case=16	,snake_case=16	,snake_case=0.02	,):



           '''simple docstring'''







           lowercase							:  Union[str, Any] 			=   parent
           lowercase							:  List[str] 			=   batch_size
           lowercase							:  Any 			=   seq_length
           lowercase							:  Dict 			=   is_training
           lowercase							:  Dict 			=   use_labels
           lowercase							:  str 			=   vocab_size
           lowercase							:  List[str] 			=   hidden_size
           lowercase							:  Dict 			=   num_hidden_layers
           lowercase							:  str 			=   num_attention_heads
           lowercase							:  Dict 			=   intermediate_size
           lowercase							:  int 			=   hidden_act
           lowercase							:  int 			=   hidden_dropout_prob
           lowercase							:  Optional[Any] 			=   attention_probs_dropout_prob
           lowercase							:  Optional[int] 			=   max_position_embeddings
           lowercase							:  Union[str, Any] 			=   eos_token_id
           lowercase							:  List[str] 			=   pad_token_id
           lowercase							:  Union[str, Any] 			=   bos_token_id
           lowercase							:  str 			=   embed_dim
           lowercase							:  Union[str, Any] 			=   word_embed_proj_dim
           lowercase							:  Tuple 			=   initializer_range
           lowercase							:  List[Any] 			=   False
    def    _SCREAMING_SNAKE_CASE (						self   ):



           '''simple docstring'''







           lowercase							:  str 			=   np.clip(ids_tensor([self.batch_size, self.seq_length - 1]	,self.vocab_size   )	,3	,self.vocab_size   )
           lowercase							:  Dict 			=   np.concatenate((input_ids, 2 * np.ones((self.batch_size, 1)	,dtype=np.intaa   ))	,-1   )

           lowercase							:  Tuple 			=   OPTConfig(
               vocab_size=self.vocab_size	,hidden_size=self.hidden_size	,num_hidden_layers=self.num_hidden_layers	,num_attention_heads=self.num_attention_heads	,ffn_dim=self.intermediate_size	,dropout=self.hidden_dropout_prob	,attention_dropout=self.attention_probs_dropout_prob	,max_position_embeddings=self.max_position_embeddings	,eos_token_id=self.eos_token_id	,bos_token_id=self.bos_token_id	,pad_token_id=self.pad_token_id	,embed_dim=self.embed_dim	,is_encoder_decoder=snake_case	,word_embed_proj_dim=self.word_embed_proj_dim	,initializer_range=self.initializer_range	,use_cache=snake_case	,)
           lowercase							:  Optional[Any] 			=   prepare_opt_inputs_dict(snake_case	,snake_case   )
           return config, inputs_dict
    def    _SCREAMING_SNAKE_CASE (						self   ):



           '''simple docstring'''







           lowercase			,    lowercase							:  List[str] 			=   self.prepare_config_and_inputs()
           return config, inputs_dict
    def    _SCREAMING_SNAKE_CASE (						self	,snake_case	,snake_case	,snake_case   ):



           '''simple docstring'''







           lowercase							:  List[Any] 			=   20
           lowercase							:  Any 			=   model_class_name(snake_case   )

           lowercase							:  Optional[int] 			=   inputs_dict["""input_ids"""]
           lowercase							:  str 			=   inputs_dict["""attention_mask"""]

           lowercase							:  Any 			=   model.init_cache(input_ids.shape[0]	,snake_case   )
           lowercase							:  Any 			=   jnp.ones((input_ids.shape[0], max_length)	,dtype="""i4"""   )

           lowercase							:  Optional[int] 			=   jnp.broadcast_to(
               jnp.arange(input_ids.shape[-1] - 1   )[None, :]	,(input_ids.shape[0], input_ids.shape[-1] - 1)	,)
           lowercase							:  str 			=   model(
               input_ids[:, :-1]	,attention_mask=snake_case	,past_key_values=snake_case	,position_ids=snake_case	,)

           lowercase							:  Union[str, Any] 			=   jnp.array(input_ids.shape[0] * [[input_ids.shape[-1] - 1]]	,dtype="""i4"""   )
           lowercase							:  Optional[int] 			=   model(
               input_ids[:, -1:]	,attention_mask=snake_case	,past_key_values=outputs_cache.past_key_values	,position_ids=snake_case	,)

           lowercase							:  int 			=   model(snake_case   )

           lowercase							:  Tuple 			=   np.max(np.abs((outputs_cache_next[0][:, -1, :5] - outputs[0][:, -1, :5])   )   )
           self.parent.assertTrue(diff < 1e-3	,msg=f"Max diff is {diff}"   )
    def    _SCREAMING_SNAKE_CASE (						self	,snake_case	,snake_case	,snake_case   ):



           '''simple docstring'''







           lowercase							:  Optional[int] 			=   20
           lowercase							:  List[str] 			=   model_class_name(snake_case   )

           lowercase			,    lowercase							:  str 			=   (
               inputs_dict["""input_ids"""],
               inputs_dict["""attention_mask"""],
           )

           lowercase							:  Tuple 			=   jnp.concatenate(
               [
                   attention_mask,
                   jnp.zeros((attention_mask.shape[0], max_length - attention_mask.shape[1])   ),
               ]	,axis=-1	,)

           lowercase							:  int 			=   model.init_cache(input_ids.shape[0]	,snake_case   )
           lowercase							:  str 			=   jnp.broadcast_to(
               jnp.arange(input_ids.shape[-1] - 1   )[None, :]	,(input_ids.shape[0], input_ids.shape[-1] - 1)	,)

           lowercase							:  Any 			=   model(
               input_ids[:, :-1]	,attention_mask=snake_case	,past_key_values=snake_case	,position_ids=snake_case	,)
           lowercase							:  Tuple 			=   jnp.array(input_ids.shape[0] * [[input_ids.shape[-1] - 1]]	,dtype="""i4"""   )
           lowercase							:  List[Any] 			=   model(
               input_ids[:, -1:]	,past_key_values=outputs_cache.past_key_values	,attention_mask=snake_case	,position_ids=snake_case	,)

           lowercase							:  Optional[Any] 			=   model(snake_case	,attention_mask=snake_case   )

           lowercase							:  Tuple 			=   np.max(np.abs((outputs_cache_next[0][:, -1, :5] - outputs[0][:, -1, :5])   )   )
           self.parent.assertTrue(diff < 1e-3	,msg=f"Max diff is {diff}"   )






@require_flax
class __snake_case	(   lowerCAmelCase      ,			unittest.TestCase      ,			lowerCAmelCase  ):
    _a	:		Tuple=       (FlaxOPTModel, FlaxOPTForCausalLM) if is_flax_available() else ()
    _a	:		Optional[int]=       () if is_flax_available() else ()
    def    _SCREAMING_SNAKE_CASE (						self   ):



           '''simple docstring'''







           lowercase							:  Optional[int] 			=   FlaxOPTModelTester(self   )
    def    _SCREAMING_SNAKE_CASE (						self   ):



           '''simple docstring'''







           lowercase			,    lowercase							:  str 			=   self.model_tester.prepare_config_and_inputs()
           for model_class in self.all_model_classes:
                  self.model_tester.check_use_cache_forward(snake_case	,snake_case	,snake_case   )
    def    _SCREAMING_SNAKE_CASE (						self   ):



           '''simple docstring'''







           lowercase			,    lowercase							:  Optional[Any] 			=   self.model_tester.prepare_config_and_inputs()
           for model_class in self.all_model_classes:
                  self.model_tester.check_use_cache_forward_with_attn_mask(snake_case	,snake_case	,snake_case   )
    @slow
    def    _SCREAMING_SNAKE_CASE (						self   ):



           '''simple docstring'''







           for model_class_name in self.all_model_classes:
                  lowercase							:  str 			=   model_class_name.from_pretrained("""facebook/opt-125m"""   )
                  lowercase							:  str 			=   np.ones((1, 1)   ) * model.config.eos_token_id
                  lowercase							:  Tuple 			=   model(snake_case   )
                  self.assertIsNotNone(snake_case   )






@require_sentencepiece
@require_flax
class __snake_case	(   unittest.TestCase  ):
    @slow
    def    _SCREAMING_SNAKE_CASE (						self   ):



           '''simple docstring'''







           lowercase							:  List[Any] 			=   FlaxOPTModel.from_pretrained("""facebook/opt-350m"""   )
           lowercase							:  List[Any] 			=   jnp.array([[0, 31414, 232, 328, 740, 1140, 12695, 69, 46078, 1588, 2]]   )
           lowercase							:  Optional[Any] 			=   model(input_ids=snake_case   ).last_hidden_state
           lowercase							:  str 			=   (1, 11, 512)
           self.assertEqual(output.shape	,snake_case   )
           lowercase							:  Optional[Any] 			=   jnp.array(
               [[-0.2_867, -1.9_256, -0.3_062], [-1.2_711, -0.1_337, -0.1_897], [0.4_109, 0.1_187, -1.3_142]]   )
           self.assertTrue(jnp.allclose(output[:, :3, :3]	,snake_case	,atol=4e-2   )   )






@require_flax
@slow
class __snake_case	(   unittest.TestCase  ):
    def    _SCREAMING_SNAKE_CASE (						self   ):



           '''simple docstring'''







           super().setUp()
           lowercase							:  List[str] 			=   """facebook/opt-350m"""
    def    _SCREAMING_SNAKE_CASE (						self   ):



           '''simple docstring'''







           lowercase							:  Optional[Any] 			=   FlaxOPTForCausalLM.from_pretrained(self.path_model   )
           lowercase							:  Optional[Any] 			=   GPTaTokenizer.from_pretrained(self.path_model   )

           lowercase							:  str 			=   [
               """Today is a beautiful day and I want to""",
               """In the city of""",
               """Paris is the capital of France and""",
               """Computers and mobile phones have taken""",
           ]
           # verify that prompt without BOS token is identical to Metaseq -> add_special_tokens=False
           lowercase							:  Optional[int] 			=   tokenizer(snake_case	,return_tensors="""jax"""	,padding=snake_case	,add_special_tokens=snake_case   )
           lowercase							:  Dict 			=   model(inputs.input_ids	,attention_mask=inputs.attention_mask   )[0].mean(axis=-1   )
           lowercase							:  List[str] 			=   jnp.array(
               [
                   [1.3_851, -13.8_923, -10.5_229, -10.7_533, -0.2_309, -10.2_384, -0.5_365, -9.0_947, -5.1_670],
                   [-4.7_073, -10.6_276, -3.9_415, -21.5_242, -0.2_822, -0.2_822, -0.2_822, -0.2_822, -0.2_822],
                   [0.6_247, -3.4_229, -8.9_179, -1.4_297, -14.1_650, 1.4_146, -9.0_218, -0.2_703, -0.2_703],
                   [6.4_783, -1.9_913, -10.7_926, -2.3_336, 1.5_092, -0.9_974, -6.8_213, 1.3_477, 1.3_477],
               ]   )
           self.assertTrue(jnp.allclose(snake_case	,snake_case	,atol=4e-2   )   )

           lowercase							:  Optional[int] 			=   jax.jit(snake_case   )
           lowercase							:  int 			=   model(inputs.input_ids	,attention_mask=inputs.attention_mask   )[0].mean(axis=-1   )
           self.assertTrue(jnp.allclose(snake_case	,snake_case	,atol=4e-2   )   )






@require_flax
@slow
class __snake_case	(   unittest.TestCase  ):
    @property
    def    _SCREAMING_SNAKE_CASE (						self   ):



           '''simple docstring'''







           return [
               "Today is a beautiful day and I want",
               "In the city of",
               "Paris is the capital of France and",
               "Computers and mobile phones have taken",
           ]
    def    _SCREAMING_SNAKE_CASE (						self   ):



           '''simple docstring'''







           lowercase							:  List[str] 			=   """facebook/opt-125m"""

           lowercase							:  Dict 			=   [
               """Today is a beautiful day and I want to""",
               """In the city of New York, the city""",
               """Paris is the capital of France and the capital""",
               """Computers and mobile phones have taken over the""",
           ]

           lowercase							:  List[Any] 			=   []

           lowercase							:  str 			=   FlaxOPTForCausalLM.from_pretrained(snake_case   )
           lowercase							:  Dict 			=   GPTaTokenizer.from_pretrained(snake_case   )

           for prompt in self.prompts:
                  lowercase							:  Any 			=   tokenizer(snake_case	,return_tensors="""jax"""   ).input_ids

                  lowercase							:  Tuple 			=   model.generate(snake_case	,max_length=10   )
                  lowercase							:  int 			=   generated_ids[0]

                  lowercase							:  List[str] 			=   tokenizer.batch_decode(snake_case	,skip_special_tokens=snake_case   )
                  predicted_outputs += generated_string

           self.assertListEqual(snake_case	,snake_case   )
    def    _SCREAMING_SNAKE_CASE (						self   ):



           '''simple docstring'''







           lowercase							:  Optional[Any] 			=   """facebook/opt-350m"""

           lowercase							:  int 			=   [
               """Today is a beautiful day and I want to""",
               """In the city of San Francisco, the city""",
               """Paris is the capital of France and the capital""",
               """Computers and mobile phones have taken over the""",
           ]

           lowercase							:  Dict 			=   []
           lowercase							:  Dict 			=   FlaxOPTForCausalLM.from_pretrained(snake_case   )
           lowercase							:  List[Any] 			=   GPTaTokenizer.from_pretrained(snake_case   )

           for prompt in self.prompts:
                  lowercase							:  Tuple 			=   tokenizer(snake_case	,return_tensors="""jax"""   ).input_ids

                  lowercase							:  int 			=   model.generate(snake_case	,max_length=10   )
                  lowercase							:  Optional[Any] 			=   generated_ids[0]

                  lowercase							:  str 			=   tokenizer.batch_decode(snake_case	,skip_special_tokens=snake_case   )
                  predicted_outputs += generated_string

           self.assertListEqual(snake_case	,snake_case   )
    def    _SCREAMING_SNAKE_CASE (						self   ):



           '''simple docstring'''







           lowercase							:  int 			=   """facebook/opt-125m"""
           lowercase							:  Dict 			=   [
               """Today is a beautiful day and I want to thank""",
               """In the city of Rome Canaver Canaver Canaver Canaver""",
           ]
           lowercase							:  List[str] 			=   FlaxOPTForCausalLM.from_pretrained(snake_case   )
           lowercase							:  List[Any] 			=   GPTaTokenizer.from_pretrained(snake_case   )
           lowercase							:  Any 			=   tokenizer(
               [
                   """Today is a beautiful day and I want to""",
                   """In the city of""",
               ]	,return_tensors="""jax"""	,padding=snake_case	,)

           lowercase							:  Optional[int] 			=   jax.jit(model.generate   )

           lowercase							:  str 			=   jit_generate(inputs["""input_ids"""]	,attention_mask=inputs["""attention_mask"""]   ).sequences

           lowercase							:  Any 			=   tokenizer.batch_decode(snake_case	,skip_special_tokens=snake_case   )

           self.assertIsNotNone(snake_case	,snake_case   )
    def    _SCREAMING_SNAKE_CASE (						self   ):



           '''simple docstring'''







           lowercase							:  Optional[int] 			=   """facebook/opt-350m"""

           lowercase							:  int 			=   GPTaTokenizer.from_pretrained(snake_case   )
           lowercase							:  Tuple 			=   FlaxOPTForCausalLM.from_pretrained(snake_case   )

           lowercase							:  Optional[Any] 			=   """left"""

           # use different length sentences to test batching
           lowercase							:  Any 			=   [
               """Hello, my dog is a little""",
               """Today, I""",
           ]

           lowercase							:  int 			=   tokenizer(snake_case	,return_tensors="""jax"""	,padding=snake_case   )
           lowercase							:  Dict 			=   inputs["""input_ids"""]

           lowercase							:  Dict 			=   model.generate(input_ids=snake_case	,attention_mask=inputs["""attention_mask"""]	,trace=snake_case   )

           lowercase							:  int 			=   tokenizer(sentences[0]	,return_tensors="""jax"""   ).input_ids
           lowercase							:  Tuple 			=   model.generate(input_ids=snake_case   )

           lowercase							:  List[str] 			=   inputs_non_padded.shape[-1] - inputs["""attention_mask"""][-1].sum()
           lowercase							:  Tuple 			=   tokenizer(sentences[1]	,return_tensors="""jax"""   ).input_ids
           lowercase							:  Optional[Any] 			=   model.generate(input_ids=snake_case	,max_length=model.config.max_length - num_paddings   )

           lowercase							:  Tuple 			=   tokenizer.batch_decode(outputs[0]	,skip_special_tokens=snake_case   )
           lowercase							:  List[Any] 			=   tokenizer.decode(output_non_padded[0][0]	,skip_special_tokens=snake_case   )
           lowercase							:  str 			=   tokenizer.decode(output_padded[0][0]	,skip_special_tokens=snake_case   )

           lowercase							:  str 			=   [
               """Hello, my dog is a little bit of a dork.\nI'm a little bit""",
               """Today, I was in the middle of a conversation with a friend about the""",
           ]
           self.assertListEqual(snake_case	,snake_case   )
           self.assertListEqual(snake_case	,[non_padded_sentence, padded_sentence]   )


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 VideoMAEImageProcessor

class __snake_case	(   unittest.TestCase  ):
    def __init__(						self	,snake_case	,snake_case=7	,snake_case=3	,snake_case=10	,snake_case=18	,snake_case=30	,snake_case=400	,snake_case=True	,snake_case=None	,snake_case=True	,snake_case=[0.5, 0.5, 0.5]	,snake_case=[0.5, 0.5, 0.5]	,snake_case=None	,):



           '''simple docstring'''







           lowercase							:  Dict 			=   size if size is not None else {"""shortest_edge""": 18}
           lowercase							:  Tuple 			=   crop_size if crop_size is not None else {"""height""": 18, """width""": 18}

           lowercase							:  Optional[int] 			=   parent
           lowercase							:  Any 			=   batch_size
           lowercase							:  int 			=   num_channels
           lowercase							:  Dict 			=   num_frames
           lowercase							:  Any 			=   image_size
           lowercase							:  str 			=   min_resolution
           lowercase							:  Any 			=   max_resolution
           lowercase							:  Tuple 			=   do_resize
           lowercase							:  Optional[Any] 			=   size
           lowercase							:  str 			=   do_normalize
           lowercase							:  Optional[Any] 			=   image_mean
           lowercase							:  Optional[Any] 			=   image_std
           lowercase							:  Union[str, Any] 			=   crop_size
    def    _SCREAMING_SNAKE_CASE (						self   ):



           '''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,
               "crop_size": self.crop_size,
           }






@require_torch
@require_vision
class __snake_case	(   lowerCAmelCase      ,			unittest.TestCase  ):
    _a	:		Optional[Any]=       VideoMAEImageProcessor if is_vision_available() else None
    def    _SCREAMING_SNAKE_CASE (						self   ):



           '''simple docstring'''







           lowercase							:  Any 			=   VideoMAEImageProcessingTester(self   )
    @property
    def    _SCREAMING_SNAKE_CASE (						self   ):



           '''simple docstring'''







           return self.image_processor_tester.prepare_image_processor_dict()
    def    _SCREAMING_SNAKE_CASE (						self   ):



           '''simple docstring'''







           lowercase							:  Any 			=   self.image_processing_class(**self.image_processor_dict   )
           self.assertTrue(hasattr(snake_case	,"""image_mean"""   )   )
           self.assertTrue(hasattr(snake_case	,"""image_std"""   )   )
           self.assertTrue(hasattr(snake_case	,"""do_normalize"""   )   )
           self.assertTrue(hasattr(snake_case	,"""do_resize"""   )   )
           self.assertTrue(hasattr(snake_case	,"""do_center_crop"""   )   )
           self.assertTrue(hasattr(snake_case	,"""size"""   )   )
    def    _SCREAMING_SNAKE_CASE (						self   ):



           '''simple docstring'''







           lowercase							:  List[str] 			=   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}   )

           lowercase							:  Any 			=   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    _SCREAMING_SNAKE_CASE (						self   ):



           '''simple docstring'''







           pass
    def    _SCREAMING_SNAKE_CASE (						self   ):



           '''simple docstring'''







           lowercase							:  Tuple 			=   self.image_processing_class(**self.image_processor_dict   )
           # create random PIL videos
           lowercase							:  Optional[int] 			=   prepare_video_inputs(self.image_processor_tester	,equal_resolution=snake_case   )
           for video in video_inputs:
                  self.assertIsInstance(snake_case	,snake_case   )
                  self.assertIsInstance(video[0]	,Image.Image   )

           # Test not batched input
           lowercase							:  Optional[Any] 			=   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
           lowercase							:  Union[str, Any] 			=   image_processing(snake_case	,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    _SCREAMING_SNAKE_CASE (						self   ):



           '''simple docstring'''







           lowercase							:  Dict 			=   self.image_processing_class(**self.image_processor_dict   )
           # create random numpy tensors
           lowercase							:  Optional[Any] 			=   prepare_video_inputs(self.image_processor_tester	,equal_resolution=snake_case	,numpify=snake_case   )
           for video in video_inputs:
                  self.assertIsInstance(snake_case	,snake_case   )
                  self.assertIsInstance(video[0]	,np.ndarray   )

           # Test not batched input
           lowercase							:  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
           lowercase							:  Optional[int] 			=   image_processing(snake_case	,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    _SCREAMING_SNAKE_CASE (						self   ):



           '''simple docstring'''







           lowercase							:  Dict 			=   self.image_processing_class(**self.image_processor_dict   )
           # create random PyTorch tensors
           lowercase							:  List[str] 			=   prepare_video_inputs(self.image_processor_tester	,equal_resolution=snake_case	,torchify=snake_case   )
           for video in video_inputs:
                  self.assertIsInstance(snake_case	,snake_case   )
                  self.assertIsInstance(video[0]	,torch.Tensor   )

           # Test not batched input
           lowercase							:  Optional[Any] 			=   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
           lowercase							:  Union[str, Any] 			=   image_processing(snake_case	,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"""],
               )	,)
