
'''simple docstring'''







import tempfile
import unittest

import numpy as np

import transformers
from transformers import GPTaConfig, GPTaTokenizer, is_flax_available, is_torch_available
from transformers.testing_utils import is_pt_flax_cross_test, require_flax, slow

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


if is_flax_available():
					import jax
					import jax.numpy as jnp

					from transformers.modeling_flax_pytorch_utils import (
					    convert_pytorch_state_dict_to_flax,
					    load_flax_weights_in_pytorch_model,
					)
					from transformers.models.gpta.modeling_flax_gpta import FlaxGPTaLMHeadModel, FlaxGPTaModel

if is_torch_available():
					import torch
class  SCREAMING_SNAKE_CASE__       :
	def __init__(				self  ,    __UpperCamelCase  ,    __UpperCamelCase=14  ,    __UpperCamelCase=7  ,    __UpperCamelCase=True  ,    __UpperCamelCase=True  ,    __UpperCamelCase=False  ,    __UpperCamelCase=True  ,    __UpperCamelCase=99  ,    __UpperCamelCase=32  ,    __UpperCamelCase=5  ,    __UpperCamelCase=4  ,    __UpperCamelCase=37  ,    __UpperCamelCase="gelu"  ,    __UpperCamelCase=0.1  ,    __UpperCamelCase=0.1  ,    __UpperCamelCase=512  ,    __UpperCamelCase=0.0_2  ,    ):



					'''simple docstring'''






					__a       :     Optional[int]								=	parent
					__a       :     Dict								=	batch_size
					__a       :     Optional[Any]								=	seq_length
					__a       :     List[Any]								=	is_training
					__a       :     List[str]								=	use_input_mask
					__a       :     Dict								=	use_token_type_ids
					__a       :     int								=	use_labels
					__a       :     List[str]								=	vocab_size
					__a       :     List[str]								=	hidden_size
					__a       :     Dict								=	num_hidden_layers
					__a       :     str								=	num_attention_heads
					__a       :     Dict								=	intermediate_size
					__a       :     List[Any]								=	hidden_act
					__a       :     Dict								=	hidden_dropout_prob
					__a       :     str								=	attention_probs_dropout_prob
					__a       :     Union[str, Any]								=	max_position_embeddings
					__a       :     Dict								=	initializer_range
					__a       :     List[Any]								=	None
					__a       :     Optional[Any]								=	vocab_size - 1
					__a       :     List[str]								=	vocab_size - 1
					__a       :     str								=	vocab_size - 1
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






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

					__a       :     str								=	None
					if self.use_input_mask:
									__a       :     List[str]								=	random_attention_mask([self.batch_size, self.seq_length]			)

					__a       :     List[str]								=	GPTaConfig(
					    vocab_size=self.vocab_size  ,    n_embd=self.hidden_size  ,    n_layer=self.num_hidden_layers  ,    n_head=self.num_attention_heads  ,    n_positions=self.max_position_embeddings  ,    use_cache=__UpperCamelCase  ,    bos_token_id=self.bos_token_id  ,    eos_token_id=self.eos_token_id  ,    pad_token_id=self.pad_token_id  ,    )

					return (config, input_ids, input_mask)
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     Any								=	self.prepare_config_and_inputs()
					__a							,	__a							,	__a       :     Any								=	config_and_inputs
					__a       :     Tuple								=	{"""input_ids""": input_ids, """attention_mask""": attention_mask}
					return config, inputs_dict
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a							,	__a							,	__a       :     Optional[int]								=	self.prepare_config_and_inputs()

					__a       :     Dict								=	floats_tensor([self.batch_size, self.seq_length, self.hidden_size]			)
					__a       :     Optional[Any]								=	ids_tensor([self.batch_size, self.seq_length]  ,    vocab_size=2			)

					return (
					    config,
					    input_ids,
					    attention_mask,
					    encoder_hidden_states,
					    encoder_attention_mask,
					)
	def __lowerCamelCase    (				self  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase			):



					'''simple docstring'''






					__a       :     Union[str, Any]								=	20
					__a       :     Any								=	model_class_name(__UpperCamelCase			)

					__a       :     Optional[int]								=	model.init_cache(input_ids.shape[0]  ,    __UpperCamelCase			)
					__a       :     Dict								=	jnp.ones((input_ids.shape[0], max_decoder_length)  ,    dtype="""i4"""			)

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

					__a       :     Dict								=	jnp.array(input_ids.shape[0] * [[input_ids.shape[-1] - 1]]  ,    dtype="""i4"""			)
					__a       :     Any								=	model(
					    input_ids[:, -1:]  ,    attention_mask=__UpperCamelCase  ,    past_key_values=outputs_cache.past_key_values  ,    position_ids=__UpperCamelCase  ,    )

					__a       :     Union[str, Any]								=	model(__UpperCamelCase			)

					__a       :     Any								=	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 __lowerCamelCase    (				self  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase			):



					'''simple docstring'''






					__a       :     Union[str, Any]								=	20
					__a       :     List[Any]								=	model_class_name(__UpperCamelCase			)

					__a       :     Optional[int]								=	jnp.concatenate(
					    [attention_mask, jnp.zeros((attention_mask.shape[0], max_decoder_length - attention_mask.shape[1])			)]  ,    axis=-1  ,    )

					__a       :     Optional[int]								=	model.init_cache(input_ids.shape[0]  ,    __UpperCamelCase			)
					__a       :     List[Any]								=	jnp.broadcast_to(
					    jnp.arange(input_ids.shape[-1] - 1			)[None, :]  ,    (input_ids.shape[0], input_ids.shape[-1] - 1)			)

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

					__a       :     Any								=	model(__UpperCamelCase  ,    attention_mask=__UpperCamelCase			)

					__a       :     Optional[int]								=	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  SCREAMING_SNAKE_CASE__       (  __UpperCamelCase			,					__UpperCamelCase			,					unittest.TestCase   ):
	lowercase__	    =							(FlaxGPTaModel, FlaxGPTaLMHeadModel) if is_flax_available() else ()
	lowercase__	    =							(FlaxGPTaLMHeadModel,) if is_flax_available() else ()
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     List[Any]								=	FlaxGPTaModelTester(self			)
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					for model_class_name in self.all_model_classes:
									__a							,	__a							,	__a       :     str								=	self.model_tester.prepare_config_and_inputs()
									self.model_tester.check_use_cache_forward(__UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase			)
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					for model_class_name in self.all_model_classes:
									__a							,	__a							,	__a       :     Tuple								=	self.model_tester.prepare_config_and_inputs()
									self.model_tester.check_use_cache_forward_with_attn_mask(
									    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase  ,    __UpperCamelCase			)
	@slow
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     Dict								=	GPTaTokenizer.from_pretrained("""gpt2"""  ,    pad_token="""</s>"""  ,    padding_side="""left"""			)
					__a       :     Dict								=	tokenizer(["""Hello this is a long string""", """Hey"""]  ,    return_tensors="""np"""  ,    padding=__UpperCamelCase  ,    truncation=__UpperCamelCase			)

					__a       :     Union[str, Any]								=	FlaxGPTaLMHeadModel.from_pretrained("""gpt2"""			)
					__a       :     Tuple								=	False
					__a       :     Any								=	model.config.eos_token_id

					__a       :     Union[str, Any]								=	jax.jit(model.generate			)

					__a       :     Tuple								=	jit_generate(inputs["""input_ids"""]  ,    attention_mask=inputs["""attention_mask"""]			).sequences

					__a       :     Dict								=	tokenizer.batch_decode(__UpperCamelCase  ,    skip_special_tokens=__UpperCamelCase			)

					__a       :     List[Any]								=	[
					    """Hello this is a long string of words. I'm going to start with the first one.\n""",
					    """Hey, I'm not sure if I'm going to be able to do""",
					]

					self.assertListEqual(__UpperCamelCase  ,    __UpperCamelCase			)
	@is_pt_flax_cross_test
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a							,	__a       :     Optional[int]								=	self.model_tester.prepare_config_and_inputs_for_common()

					for model_class in self.all_model_classes:
									with self.subTest(model_class.__name__			):
													# prepare inputs
													__a       :     Optional[Any]								=	self._prepare_for_class(__UpperCamelCase  ,    __UpperCamelCase			)
													__a       :     Tuple								=	{k: torch.tensor(v.tolist()			) for k, v in prepared_inputs_dict.items()}

													# load corresponding PyTorch class
													__a       :     List[Any]								=	model_class.__name__[4:]  # Skip the "Flax" at the beginning
													__a       :     Optional[int]								=	getattr(__UpperCamelCase  ,    __UpperCamelCase			)

													__a							,	__a       :     Any								=	pt_inputs["""input_ids"""].shape
													__a       :     List[Any]								=	np.random.randint(0  ,    seq_length - 1  ,    size=(batch_size,)			)
													for batch_idx, start_index in enumerate(__UpperCamelCase			):
																	__a       :     Union[str, Any]								=	0
																	__a       :     Any								=	1
																	__a       :     Dict								=	0
																	__a       :     Dict								=	1
													__a       :     int								=	pt_model_class(__UpperCamelCase			).eval()
													__a       :     Dict								=	model_class(__UpperCamelCase  ,    dtype=jnp.floataa			)

													__a       :     Tuple								=	convert_pytorch_state_dict_to_flax(pt_model.state_dict()  ,    __UpperCamelCase			)
													__a       :     List[str]								=	fx_state

													with torch.no_grad():
																	__a       :     List[Any]								=	pt_model(**__UpperCamelCase			).to_tuple()

													__a       :     str								=	fx_model(**__UpperCamelCase			).to_tuple()
													self.assertEqual(len(__UpperCamelCase			)  ,    len(__UpperCamelCase			)  ,    """Output lengths differ between Flax and PyTorch"""			)
													for fx_output, pt_output in zip(__UpperCamelCase  ,    __UpperCamelCase			):
																	self.assert_almost_equals(fx_output[:, -1]  ,    pt_output[:, -1].numpy()  ,    4E-2			)

													with tempfile.TemporaryDirectory() as tmpdirname:
																	pt_model.save_pretrained(__UpperCamelCase			)
																	__a       :     Union[str, Any]								=	model_class.from_pretrained(__UpperCamelCase  ,    from_pt=__UpperCamelCase			)

													__a       :     int								=	fx_model_loaded(**__UpperCamelCase			).to_tuple()
													self.assertEqual(
													    len(__UpperCamelCase			)  ,    len(__UpperCamelCase			)  ,    """Output lengths differ between Flax and PyTorch"""			)
													for fx_output_loaded, pt_output in zip(__UpperCamelCase  ,    __UpperCamelCase			):
																	self.assert_almost_equals(fx_output_loaded[:, -1]  ,    pt_output[:, -1].numpy()  ,    4E-2			)
	@is_pt_flax_cross_test
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a							,	__a       :     Optional[int]								=	self.model_tester.prepare_config_and_inputs_for_common()
					for model_class in self.all_model_classes:
									with self.subTest(model_class.__name__			):
													# prepare inputs
													__a       :     Tuple								=	self._prepare_for_class(__UpperCamelCase  ,    __UpperCamelCase			)
													__a       :     Optional[Any]								=	{k: torch.tensor(v.tolist()			) for k, v in prepared_inputs_dict.items()}

													# load corresponding PyTorch class
													__a       :     Optional[Any]								=	model_class.__name__[4:]  # Skip the "Flax" at the beginning
													__a       :     Optional[Any]								=	getattr(__UpperCamelCase  ,    __UpperCamelCase			)

													__a       :     List[Any]								=	pt_model_class(__UpperCamelCase			).eval()
													__a       :     Dict								=	model_class(__UpperCamelCase  ,    dtype=jnp.floataa			)

													__a       :     int								=	load_flax_weights_in_pytorch_model(__UpperCamelCase  ,    fx_model.params			)
													__a							,	__a       :     Tuple								=	pt_inputs["""input_ids"""].shape
													__a       :     Optional[Any]								=	np.random.randint(0  ,    seq_length - 1  ,    size=(batch_size,)			)
													for batch_idx, start_index in enumerate(__UpperCamelCase			):
																	__a       :     List[str]								=	0
																	__a       :     Union[str, Any]								=	1
																	__a       :     Tuple								=	0
																	__a       :     Optional[int]								=	1

													# make sure weights are tied in PyTorch
													pt_model.tie_weights()

													with torch.no_grad():
																	__a       :     Tuple								=	pt_model(**__UpperCamelCase			).to_tuple()

													__a       :     Optional[Any]								=	fx_model(**__UpperCamelCase			).to_tuple()
													self.assertEqual(len(__UpperCamelCase			)  ,    len(__UpperCamelCase			)  ,    """Output lengths differ between Flax and PyTorch"""			)
													for fx_output, pt_output in zip(__UpperCamelCase  ,    __UpperCamelCase			):
																	self.assert_almost_equals(fx_output[:, -1]  ,    pt_output[:, -1].numpy()  ,    4E-2			)

													with tempfile.TemporaryDirectory() as tmpdirname:
																	fx_model.save_pretrained(__UpperCamelCase			)
																	__a       :     str								=	pt_model_class.from_pretrained(__UpperCamelCase  ,    from_flax=__UpperCamelCase			)

													with torch.no_grad():
																	__a       :     Any								=	pt_model_loaded(**__UpperCamelCase			).to_tuple()

													self.assertEqual(
													    len(__UpperCamelCase			)  ,    len(__UpperCamelCase			)  ,    """Output lengths differ between Flax and PyTorch"""			)
													for fx_output, pt_output in zip(__UpperCamelCase  ,    __UpperCamelCase			):
																	self.assert_almost_equals(fx_output[:, -1]  ,    pt_output[:, -1].numpy()  ,    4E-2			)

	@slow
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					for model_class_name in self.all_model_classes:
									__a       :     str								=	model_class_name.from_pretrained("""gpt2"""  ,    from_pt=__UpperCamelCase			)
									__a       :     List[Any]								=	model(np.ones((1, 1)			)			)
									self.assertIsNotNone(__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 				_snake_case (		lowercase			,    lowercase=1_0			,    lowercase=1_0			,    lowercase=False			,    lowercase=False						)       ->       Any:
				__a       :     Union[str, 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
								__a       :     Optional[Any]								=	[Image.fromarray(np.moveaxis(lowercase			,    0			,    -1						)						) for frame in video]

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

				return video

def 				_snake_case (		lowercase			,    lowercase=False			,    lowercase=False			,    lowercase=False						)       ->       Optional[Any]:
				assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

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

				return video_inputs
class  SCREAMING_SNAKE_CASE__       (  unittest.TestCase   ):
	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  ,    ):



					'''simple docstring'''






					__a       :     int								=	size if size is not None else {"""shortest_edge""": 18}
					__a       :     Optional[int]								=	crop_size if crop_size is not None else {"""height""": 18, """width""": 18}

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

	def __lowerCamelCase    (				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,
					    "do_center_crop": self.do_center_crop,
					    "crop_size": self.crop_size,
					}







@require_torch
@require_vision
class  SCREAMING_SNAKE_CASE__       (  __UpperCamelCase			,					unittest.TestCase   ):
	lowercase__	    =							TvltImageProcessor if is_vision_available() else None
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     Optional[int]								=	TvltImageProcessorTester(self			)
	@property
	def __lowerCamelCase    (				self			):



					'''simple docstring'''






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



					'''simple docstring'''






					__a       :     Optional[Any]								=	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 __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     Union[str, Any]								=	self.image_processing_class(**self.image_processor_dict			)
					# create random PIL videos
					__a       :     List[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
					__a       :     int								=	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       :     int								=	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 __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     List[str]								=	self.image_processing_class(**self.image_processor_dict			)
					# create random numpy tensors
					__a       :     Union[str, Any]								=	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
					__a       :     Optional[int]								=	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       :     Dict								=	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 __lowerCamelCase    (				self			):



					'''simple docstring'''






					__a       :     Optional[Any]								=	self.image_processing_class(**self.image_processor_dict			)
					# create random PyTorch tensors
					__a       :     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
					__a       :     Optional[int]								=	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       :     int								=	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"""],
					    )  ,    )