import copy
import inspect
import unittest

import numpy as np
from huggingface_hub import hf_hub_download

from transformers import VideoMAEConfig
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, require_vision, 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
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
						import torch
						from torch import nn

						from transformers import (
						    MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING,
						    VideoMAEForPreTraining,
						    VideoMAEForVideoClassification,
						    VideoMAEModel,
						)
						from transformers.models.videomae.modeling_videomae import VIDEOMAE_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
						from transformers import VideoMAEImageProcessor






class      __lowercase					:

						def __init__(	self				:      Optional[Any]							,							__lowerCamelCase				:      List[Any]							,							__lowerCamelCase				:      List[Any]=13							,							__lowerCamelCase				:      Optional[int]=10							,							__lowerCamelCase				:      Tuple=3							,							__lowerCamelCase				:      int=2							,							__lowerCamelCase				:      Tuple=2							,							__lowerCamelCase				:      Any=2							,							__lowerCamelCase				:      Optional[Any]=True							,							__lowerCamelCase				:      int=True							,							__lowerCamelCase				:      Any=32							,							__lowerCamelCase				:      List[Any]=5							,							__lowerCamelCase				:      List[Any]=4							,							__lowerCamelCase				:      List[str]=37							,							__lowerCamelCase				:      int="gelu"							,							__lowerCamelCase				:      Optional[Any]=0.1							,							__lowerCamelCase				:      Optional[int]=0.1							,							__lowerCamelCase				:      Optional[Any]=10							,							__lowerCamelCase				:      List[str]=0.02							,							__lowerCamelCase				:      List[Any]=0.9							,							__lowerCamelCase				:      Any=None							,							)							->		Optional[Any]:


									'''simple docstring'''

									lowercase							=		parent
									lowercase							=		batch_size
									lowercase							=		image_size
									lowercase							=		num_channels
									lowercase							=		patch_size
									lowercase							=		tubelet_size
									lowercase							=		num_frames
									lowercase							=		is_training
									lowercase							=		use_labels
									lowercase							=		hidden_size
									lowercase							=		num_hidden_layers
									lowercase							=		num_attention_heads
									lowercase							=		intermediate_size
									lowercase							=		hidden_act
									lowercase							=		hidden_dropout_prob
									lowercase							=		attention_probs_dropout_prob
									lowercase							=		type_sequence_label_size
									lowercase							=		initializer_range
									lowercase							=		mask_ratio
									lowercase							=		scope

									# in VideoMAE, the number of tokens equals num_frames/tubelet_size * num_patches per frame
									lowercase							=		(image_size // patch_size) ** 2
									lowercase							=		(num_frames // tubelet_size) * self.num_patches_per_frame

									# use this variable to define bool_masked_pos
									lowercase							=		int(mask_ratio * self.seq_length   )

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


									'''simple docstring'''

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

									lowercase							=		None
									if self.use_labels:
												lowercase							=		ids_tensor([self.batch_size]							,							self.type_sequence_label_size   )

									lowercase							=		self.get_config()

									return config, pixel_values, labels

						def        __a		(	self				:      Optional[Any]   )							->		Tuple:


									'''simple docstring'''

									return VideoMAEConfig(
									    image_size=self.image_size							,							patch_size=self.patch_size							,							num_channels=self.num_channels							,							num_frames=self.num_frames							,							tubelet_size=self.tubelet_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							,							is_decoder=__lowerCamelCase							,							initializer_range=self.initializer_range							,							)

						def        __a		(	self				:      str							,							__lowerCamelCase				:      int							,							__lowerCamelCase				:      Optional[Any]							,							__lowerCamelCase				:      List[Any]   )							->		List[str]:


									'''simple docstring'''

									lowercase							=		VideoMAEModel(config=__lowerCamelCase   )
									model.to(__lowerCamelCase   )
									model.eval()
									lowercase							=		model(__lowerCamelCase   )
									self.parent.assertEqual(result.last_hidden_state.shape							,							(self.batch_size, self.seq_length, self.hidden_size)   )

						def        __a		(	self				:      int							,							__lowerCamelCase				:      List[str]							,							__lowerCamelCase				:      Any							,							__lowerCamelCase				:      List[Any]   )							->		Dict:


									'''simple docstring'''

									lowercase							=		VideoMAEForPreTraining(__lowerCamelCase   )
									model.to(__lowerCamelCase   )
									model.eval()
									# important: each video needs to have the same number of masked patches
									# hence we define a single mask, which we then repeat for each example in the batch
									lowercase							=		torch.ones((self.num_masks,)   )
									lowercase							=		torch.cat([mask, torch.zeros(self.seq_length - mask.size(0   )   )]   )
									lowercase							=		mask.expand(self.batch_size							,							-1   ).bool()

									lowercase							=		model(__lowerCamelCase							,							__lowerCamelCase   )
									# model only returns predictions for masked patches
									lowercase							=		mask.sum().item()
									lowercase							=		3 * self.tubelet_size * self.patch_size**2
									self.parent.assertEqual(result.logits.shape							,							(self.batch_size, num_masked_patches, decoder_num_labels)   )



						def        __a		(	self				:      int   )							->		Tuple:


									'''simple docstring'''

									lowercase							=		self.prepare_config_and_inputs()
									lowercase		,lowercase		,lowercase							=		config_and_inputs
									lowercase							=		{'''pixel_values''': pixel_values}
									return config, inputs_dict






@require_torch
class      __lowercase					(    _A       ,     _A       ,     unittest.TestCase    ):
						lowercase					 =     (
						    (VideoMAEModel, VideoMAEForPreTraining, VideoMAEForVideoClassification) if is_torch_available() else ()
						)
						lowercase					 =     (
						    {'feature-extraction': VideoMAEModel, 'video-classification': VideoMAEForVideoClassification}
						    if is_torch_available()
						    else {}
						)

						lowercase					 =     False
						lowercase					 =     False
						lowercase					 =     False
						lowercase					 =     False

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


									'''simple docstring'''

									lowercase							=		VideoMAEModelTester(self   )
									lowercase							=		ConfigTester(self							,							config_class=__lowerCamelCase							,							has_text_modality=__lowerCamelCase							,							hidden_size=37   )

						def        __a		(	self				:      str							,							__lowerCamelCase				:      str							,							__lowerCamelCase				:      Optional[Any]							,							__lowerCamelCase				:      Optional[int]=False   )							->		Optional[int]:


									'''simple docstring'''

									lowercase							=		copy.deepcopy(__lowerCamelCase   )

									if model_class == VideoMAEForPreTraining:
												# important: each video needs to have the same number of masked patches
												# hence we define a single mask, which we then repeat for each example in the batch
												lowercase							=		torch.ones((self.model_tester.num_masks,)   )
												lowercase							=		torch.cat([mask, torch.zeros(self.model_tester.seq_length - mask.size(0   )   )]   )
												lowercase							=		mask.expand(self.model_tester.batch_size							,							-1   ).bool()
												lowercase							=		bool_masked_pos.to(__lowerCamelCase   )

									if return_labels:
												if model_class in [
												    *get_values(__lowerCamelCase   ),
												]:
															lowercase							=		torch.zeros(
															    self.model_tester.batch_size							,							dtype=torch.long							,							device=__lowerCamelCase   )

									return inputs_dict

						def        __a		(	self				:      Optional[int]   )							->		Optional[Any]:


									'''simple docstring'''

									self.config_tester.run_common_tests()

						@unittest.skip(reason='''VideoMAE does not use inputs_embeds'''   )
						def        __a		(	self				:      Tuple   )							->		Optional[int]:


									'''simple docstring'''

									pass

						def        __a		(	self				:      Any   )							->		Dict:


									'''simple docstring'''

									lowercase		,lowercase							=		self.model_tester.prepare_config_and_inputs_for_common()

									for model_class in self.all_model_classes:
												lowercase							=		model_class(__lowerCamelCase   )
												self.assertIsInstance(model.get_input_embeddings()							,							(nn.Module)   )
												lowercase							=		model.get_output_embeddings()
												self.assertTrue(x is None or isinstance(__lowerCamelCase							,							nn.Linear   )   )

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


									'''simple docstring'''

									lowercase		,lowercase							=		self.model_tester.prepare_config_and_inputs_for_common()

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

												lowercase							=		['''pixel_values''']
												self.assertListEqual(arg_names[:1]							,							__lowerCamelCase   )

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


									'''simple docstring'''

									lowercase							=		self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_model(*__lowerCamelCase   )

						def        __a		(	self				:      Any   )							->		List[Any]:


									'''simple docstring'''

									lowercase							=		self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_pretraining(*__lowerCamelCase   )

						@slow
						def        __a		(	self				:      Any   )							->		int:


									'''simple docstring'''

									for model_name in VIDEOMAE_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
												lowercase							=		VideoMAEModel.from_pretrained(__lowerCamelCase   )
												self.assertIsNotNone(__lowerCamelCase   )

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


									'''simple docstring'''

									if not self.has_attentions:
												pass

									else:
												lowercase		,lowercase							=		self.model_tester.prepare_config_and_inputs_for_common()
												lowercase							=		True

												for model_class in self.all_model_classes:
															lowercase							=		self.model_tester.seq_length - self.model_tester.num_masks
															lowercase							=		(
															    num_visible_patches if model_class == VideoMAEForPreTraining else self.model_tester.seq_length
															)

															lowercase							=		True
															lowercase							=		False
															lowercase							=		True
															lowercase							=		model_class(__lowerCamelCase   )
															model.to(__lowerCamelCase   )
															model.eval()
															with torch.no_grad():
																		lowercase							=		model(**self._prepare_for_class(__lowerCamelCase							,							__lowerCamelCase   )   )
															lowercase							=		outputs.attentions
															self.assertEqual(len(__lowerCamelCase   )							,							self.model_tester.num_hidden_layers   )

															# check that output_attentions also work using config
															del inputs_dict["output_attentions"]
															lowercase							=		True
															lowercase							=		model_class(__lowerCamelCase   )
															model.to(__lowerCamelCase   )
															model.eval()
															with torch.no_grad():
																		lowercase							=		model(**self._prepare_for_class(__lowerCamelCase							,							__lowerCamelCase   )   )
															lowercase							=		outputs.attentions
															self.assertEqual(len(__lowerCamelCase   )							,							self.model_tester.num_hidden_layers   )

															self.assertListEqual(
															    list(attentions[0].shape[-3:]   )							,							[self.model_tester.num_attention_heads, seq_len, seq_len]							,							)
															lowercase							=		len(__lowerCamelCase   )

															# Check attention is always last and order is fine
															lowercase							=		True
															lowercase							=		True
															lowercase							=		model_class(__lowerCamelCase   )
															model.to(__lowerCamelCase   )
															model.eval()
															with torch.no_grad():
																		lowercase							=		model(**self._prepare_for_class(__lowerCamelCase							,							__lowerCamelCase   )   )

															self.assertEqual(out_len + 1							,							len(__lowerCamelCase   )   )

															lowercase							=		outputs.attentions

															self.assertEqual(len(__lowerCamelCase   )							,							self.model_tester.num_hidden_layers   )
															self.assertListEqual(
															    list(self_attentions[0].shape[-3:]   )							,							[self.model_tester.num_attention_heads, seq_len, seq_len]							,							)

						def        __a		(	self				:      Dict   )							->		List[str]:


									'''simple docstring'''

									def check_hidden_states_output(__lowerCamelCase				:      Optional[Any]							,							__lowerCamelCase				:      Optional[Any]							,							__lowerCamelCase				:      List[Any]   ):
												lowercase							=		model_class(__lowerCamelCase   )
												model.to(__lowerCamelCase   )
												model.eval()

												with torch.no_grad():
															lowercase							=		model(**self._prepare_for_class(__lowerCamelCase							,							__lowerCamelCase   )   )

												lowercase							=		outputs.hidden_states
												lowercase							=		self.model_tester.num_hidden_layers + 1
												self.assertEqual(len(__lowerCamelCase   )							,							__lowerCamelCase   )

												lowercase							=		self.model_tester.seq_length - self.model_tester.num_masks
												lowercase							=		num_visible_patches if model_class == VideoMAEForPreTraining else self.model_tester.seq_length

												self.assertListEqual(
												    list(hidden_states[0].shape[-2:]   )							,							[seq_length, self.model_tester.hidden_size]							,							)

									lowercase		,lowercase							=		self.model_tester.prepare_config_and_inputs_for_common()

									for model_class in self.all_model_classes:
												lowercase							=		True
												check_hidden_states_output(__lowerCamelCase							,							__lowerCamelCase							,							__lowerCamelCase   )

												# check that output_hidden_states also work using config
												del inputs_dict["output_hidden_states"]
												lowercase							=		True

												check_hidden_states_output(__lowerCamelCase							,							__lowerCamelCase							,							__lowerCamelCase   )



						@unittest.skip('''Will be fixed soon by reducing the size of the model used for common tests.'''   )
						def        __a		(	self				:      str   )							->		int:


									'''simple docstring'''

									pass






def        __UpperCAmelCase    (						)->       List[str]:



			"""simple docstring"""







			lowercase							=		hf_hub_download(
			    repo_id='''hf-internal-testing/spaghetti-video''',		filename='''eating_spaghetti.npy''',		repo_type='''dataset'''       )
			lowercase							=		np.load(UpperCAmelCase       )
			return list(UpperCAmelCase       )






@require_torch
@require_vision
class      __lowercase					(    unittest.TestCase    ):

						@cached_property
						def        __a		(	self				:      Dict   )							->		str:


									'''simple docstring'''

									return (
									    VideoMAEImageProcessor(image_mean=[0.5, 0.5, 0.5]							,							image_std=[0.5, 0.5, 0.5]   )
									    if is_vision_available()
									    else None
									)

						@slow
						def        __a		(	self				:      List[Any]   )							->		List[Any]:


									'''simple docstring'''

									lowercase							=		VideoMAEForVideoClassification.from_pretrained('''MCG-NJU/videomae-base-finetuned-kinetics'''   ).to(
									    __lowerCamelCase   )

									lowercase							=		self.default_image_processor
									lowercase							=		prepare_video()
									lowercase							=		image_processor(__lowerCamelCase							,							return_tensors='''pt'''   ).to(__lowerCamelCase   )

									# forward pass
									with torch.no_grad():
												lowercase							=		model(**__lowerCamelCase   )

									# verify the logits
									lowercase							=		torch.Size((1, 4_00)   )
									self.assertEqual(outputs.logits.shape							,							__lowerCamelCase   )

									lowercase							=		torch.tensor([0.3669, -0.0688, -0.2421]   ).to(__lowerCamelCase   )

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



						@slow
						def        __a		(	self				:      Any   )							->		Optional[Any]:


									'''simple docstring'''

									lowercase							=		VideoMAEForPreTraining.from_pretrained('''MCG-NJU/videomae-base-short'''   ).to(__lowerCamelCase   )

									lowercase							=		self.default_image_processor
									lowercase							=		prepare_video()
									lowercase							=		image_processor(__lowerCamelCase							,							return_tensors='''pt'''   ).to(__lowerCamelCase   )

									# add boolean mask, indicating which patches to mask
									lowercase							=		hf_hub_download(repo_id='''hf-internal-testing/bool-masked-pos'''							,							filename='''bool_masked_pos.pt'''   )
									lowercase							=		torch.load(__lowerCamelCase   )

									# forward pass
									with torch.no_grad():
												lowercase							=		model(**__lowerCamelCase   )

									# verify the logits
									lowercase							=		torch.Size([1, 14_08, 15_36]   )
									lowercase							=		torch.tensor(
									    [[0.7994, 0.9612, 0.8508], [0.7401, 0.8958, 0.8302], [0.5862, 0.7468, 0.7325]]							,							device=__lowerCamelCase   )
									self.assertEqual(outputs.logits.shape							,							__lowerCamelCase   )
									self.assertTrue(torch.allclose(outputs.logits[0, :3, :3]							,							__lowerCamelCase							,							atol=1E-4   )   )

									# verify the loss (`config.norm_pix_loss` = `True`)
									lowercase							=		torch.tensor([0.5142]							,							device=__lowerCamelCase   )
									self.assertTrue(torch.allclose(outputs.loss							,							__lowerCamelCase							,							atol=1E-4   )   )

									# verify the loss (`config.norm_pix_loss` = `False`)
									lowercase							=		VideoMAEForPreTraining.from_pretrained('''MCG-NJU/videomae-base-short'''							,							norm_pix_loss=__lowerCamelCase   ).to(
									    __lowerCamelCase   )

									with torch.no_grad():
												lowercase							=		model(**__lowerCamelCase   )

									lowercase							=		torch.tensor(torch.tensor([0.6469]   )							,							device=__lowerCamelCase   )
									self.assertTrue(torch.allclose(outputs.loss							,							__lowerCamelCase							,							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_image_inputs


if is_torch_available():
						import torch

if is_vision_available():
						from PIL import Image

						from transformers import MobileViTImageProcessor






class      __lowercase					(    unittest.TestCase    ):

						def __init__(	self				:      int							,							__lowerCamelCase				:      Optional[Any]							,							__lowerCamelCase				:      int=7							,							__lowerCamelCase				:      Dict=3							,							__lowerCamelCase				:      Optional[int]=18							,							__lowerCamelCase				:      List[Any]=30							,							__lowerCamelCase				:      Union[str, Any]=4_00							,							__lowerCamelCase				:      Optional[int]=True							,							__lowerCamelCase				:      List[str]=None							,							__lowerCamelCase				:      Dict=True							,							__lowerCamelCase				:      Dict=None							,							__lowerCamelCase				:      Tuple=True							,							)							->		Tuple:


									'''simple docstring'''

									lowercase							=		size if size is not None else {'''shortest_edge''': 20}
									lowercase							=		crop_size if crop_size is not None else {'''height''': 18, '''width''': 18}
									lowercase							=		parent
									lowercase							=		batch_size
									lowercase							=		num_channels
									lowercase							=		image_size
									lowercase							=		min_resolution
									lowercase							=		max_resolution
									lowercase							=		do_resize
									lowercase							=		size
									lowercase							=		do_center_crop
									lowercase							=		crop_size
									lowercase							=		do_flip_channel_order



						def        __a		(	self				:      Optional[int]   )							->		Any:


									'''simple docstring'''

									return {
									    "do_resize": self.do_resize,
									    "size": self.size,
									    "do_center_crop": self.do_center_crop,
									    "crop_size": self.crop_size,
									    "do_flip_channel_order": self.do_flip_channel_order,
									}






@require_torch
@require_vision
class      __lowercase					(    _A       ,     unittest.TestCase    ):
						lowercase					 =     MobileViTImageProcessor if is_vision_available() else None

						def        __a		(	self				:      Dict   )							->		Dict:


									'''simple docstring'''

									lowercase							=		MobileViTImageProcessingTester(self   )

						@property
						def        __a		(	self				:      Tuple   )							->		Dict:


									'''simple docstring'''

									return self.image_processor_tester.prepare_image_processor_dict()

						def        __a		(	self				:      Dict   )							->		List[Any]:


									'''simple docstring'''

									lowercase							=		self.image_processing_class(**self.image_processor_dict   )
									self.assertTrue(hasattr(__lowerCamelCase							,							'''do_resize'''   )   )
									self.assertTrue(hasattr(__lowerCamelCase							,							'''size'''   )   )
									self.assertTrue(hasattr(__lowerCamelCase							,							'''do_center_crop'''   )   )
									self.assertTrue(hasattr(__lowerCamelCase							,							'''center_crop'''   )   )
									self.assertTrue(hasattr(__lowerCamelCase							,							'''do_flip_channel_order'''   )   )

						def        __a		(	self				:      List[str]   )							->		str:


									'''simple docstring'''

									lowercase							=		self.image_processing_class.from_dict(self.image_processor_dict   )
									self.assertEqual(image_processor.size							,							{'''shortest_edge''': 20}   )
									self.assertEqual(image_processor.crop_size							,							{'''height''': 18, '''width''': 18}   )

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


									'''simple docstring'''

									pass

						def        __a		(	self				:      Any   )							->		List[str]:


									'''simple docstring'''

									lowercase							=		self.image_processing_class(**self.image_processor_dict   )
									# create random PIL images
									lowercase							=		prepare_image_inputs(self.image_processor_tester							,							equal_resolution=__lowerCamelCase   )
									for image in image_inputs:
												self.assertIsInstance(__lowerCamelCase							,							Image.Image   )

									# Test not batched input
									lowercase							=		image_processing(image_inputs[0]							,							return_tensors='''pt'''   ).pixel_values
									self.assertEqual(
									    encoded_images.shape							,							(
									        1,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.crop_size['''height'''],
									        self.image_processor_tester.crop_size['''width'''],
									    )							,							)

									# Test batched
									lowercase							=		image_processing(__lowerCamelCase							,							return_tensors='''pt'''   ).pixel_values
									self.assertEqual(
									    encoded_images.shape							,							(
									        self.image_processor_tester.batch_size,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.crop_size['''height'''],
									        self.image_processor_tester.crop_size['''width'''],
									    )							,							)

						def        __a		(	self				:      int   )							->		str:


									'''simple docstring'''

									lowercase							=		self.image_processing_class(**self.image_processor_dict   )
									# create random numpy tensors
									lowercase							=		prepare_image_inputs(self.image_processor_tester							,							equal_resolution=__lowerCamelCase							,							numpify=__lowerCamelCase   )
									for image in image_inputs:
												self.assertIsInstance(__lowerCamelCase							,							np.ndarray   )

									# Test not batched input
									lowercase							=		image_processing(image_inputs[0]							,							return_tensors='''pt'''   ).pixel_values
									self.assertEqual(
									    encoded_images.shape							,							(
									        1,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.crop_size['''height'''],
									        self.image_processor_tester.crop_size['''width'''],
									    )							,							)

									# Test batched
									lowercase							=		image_processing(__lowerCamelCase							,							return_tensors='''pt'''   ).pixel_values
									self.assertEqual(
									    encoded_images.shape							,							(
									        self.image_processor_tester.batch_size,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.crop_size['''height'''],
									        self.image_processor_tester.crop_size['''width'''],
									    )							,							)



						def        __a		(	self				:      Dict   )							->		Any:


									'''simple docstring'''

									lowercase							=		self.image_processing_class(**self.image_processor_dict   )
									# create random PyTorch tensors
									lowercase							=		prepare_image_inputs(self.image_processor_tester							,							equal_resolution=__lowerCamelCase							,							torchify=__lowerCamelCase   )
									for image in image_inputs:
												self.assertIsInstance(__lowerCamelCase							,							torch.Tensor   )

									# Test not batched input
									lowercase							=		image_processing(image_inputs[0]							,							return_tensors='''pt'''   ).pixel_values
									self.assertEqual(
									    encoded_images.shape							,							(
									        1,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.crop_size['''height'''],
									        self.image_processor_tester.crop_size['''width'''],
									    )							,							)

									# Test batched
									lowercase							=		image_processing(__lowerCamelCase							,							return_tensors='''pt'''   ).pixel_values
									self.assertEqual(
									    encoded_images.shape							,							(
									        self.image_processor_tester.batch_size,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.crop_size['''height'''],
									        self.image_processor_tester.crop_size['''width'''],
									    )							,							)





