
'''simple docstring'''







import argparse
import json
import os

import requests
import torch
from huggingface_hub import hf_hub_download
from PIL import Image

from transformers import ConvNextImageProcessor, ConvNextVaConfig, ConvNextVaForImageClassification
from transformers.image_utils import PILImageResampling
from transformers.utils import logging


logging.set_verbosity_info()
__SCREAMING_SNAKE_CASE		:  Dict        =      logging.get_logger(__name__)

def 				_snake_case (		lowercase						)       ->       Any:
				__a       :     Any								=	ConvNextVaConfig()

				if "atto" in checkpoint_url:
								__a       :     int								=	[2, 2, 6, 2]
								__a       :     Dict								=	[4_0, 8_0, 1_6_0, 3_2_0]
				if "femto" in checkpoint_url:
								__a       :     Any								=	[2, 2, 6, 2]
								__a       :     Union[str, Any]								=	[4_8, 9_6, 1_9_2, 3_8_4]
				if "pico" in checkpoint_url:
								__a       :     Tuple								=	[2, 2, 6, 2]
								__a       :     Union[str, Any]								=	[6_4, 1_2_8, 2_5_6, 5_1_2]
				if "nano" in checkpoint_url:
								__a       :     Dict								=	[2, 2, 8, 2]
								__a       :     int								=	[8_0, 1_6_0, 3_2_0, 6_4_0]
				if "tiny" in checkpoint_url:
								__a       :     Tuple								=	[3, 3, 9, 3]
								__a       :     Tuple								=	[9_6, 1_9_2, 3_8_4, 7_6_8]
				if "base" in checkpoint_url:
								__a       :     List[Any]								=	[3, 3, 2_7, 3]
								__a       :     Tuple								=	[1_2_8, 2_5_6, 5_1_2, 1_0_2_4]
				if "large" in checkpoint_url:
								__a       :     Optional[int]								=	[3, 3, 2_7, 3]
								__a       :     Optional[int]								=	[1_9_2, 3_8_4, 7_6_8, 1_5_3_6]
				if "huge" in checkpoint_url:
								__a       :     Any								=	[3, 3, 2_7, 3]
								__a       :     Optional[int]								=	[3_5_2, 7_0_4, 1_4_0_8, 2_8_1_6]

				__a       :     Any								=	1_0_0_0
				__a       :     str								=	"""imagenet-1k-id2label.json"""
				__a       :     Optional[int]								=	(1, 1_0_0_0)

				__a       :     List[str]								=	"""huggingface/label-files"""
				__a       :     str								=	num_labels
				__a       :     Union[str, Any]								=	json.load(open(hf_hub_download(lowercase			,    lowercase			,    repo_type="""dataset"""						)			,    """r"""						)						)
				__a       :     List[Any]								=	{int(lowercase						): v for k, v in idalabel.items()}

				__a       :     str								=	idalabel
				__a       :     str								=	{v: k for k, v in idalabel.items()}
				__a       :     Union[str, Any]								=	hidden_sizes
				__a       :     int								=	depths

				return config, expected_shape

def 				_snake_case (		lowercase						)       ->       Union[str, Any]:
				if "downsample_layers.0.0" in name:
								__a       :     Optional[int]								=	name.replace("""downsample_layers.0.0"""			,    """embeddings.patch_embeddings"""						)
				if "downsample_layers.0.1" in name:
								__a       :     Dict								=	name.replace("""downsample_layers.0.1"""			,    """embeddings.norm"""						)  # we rename to layernorm later on
				if "downsample_layers.1.0" in name:
								__a       :     Any								=	name.replace("""downsample_layers.1.0"""			,    """stages.1.downsampling_layer.0"""						)
				if "downsample_layers.1.1" in name:
								__a       :     Dict								=	name.replace("""downsample_layers.1.1"""			,    """stages.1.downsampling_layer.1"""						)
				if "downsample_layers.2.0" in name:
								__a       :     Union[str, Any]								=	name.replace("""downsample_layers.2.0"""			,    """stages.2.downsampling_layer.0"""						)
				if "downsample_layers.2.1" in name:
								__a       :     Optional[Any]								=	name.replace("""downsample_layers.2.1"""			,    """stages.2.downsampling_layer.1"""						)
				if "downsample_layers.3.0" in name:
								__a       :     Optional[int]								=	name.replace("""downsample_layers.3.0"""			,    """stages.3.downsampling_layer.0"""						)
				if "downsample_layers.3.1" in name:
								__a       :     List[Any]								=	name.replace("""downsample_layers.3.1"""			,    """stages.3.downsampling_layer.1"""						)
				if "stages" in name and "downsampling_layer" not in name:
								# stages.0.0. for instance should be renamed to stages.0.layers.0.
								__a       :     Tuple								=	name[: len("""stages.0"""						)] + """.layers""" + name[len("""stages.0"""						) :]
				if "gamma" in name:
								__a       :     str								=	name.replace("""gamma"""			,    """weight"""						)
				if "beta" in name:
								__a       :     Any								=	name.replace("""beta"""			,    """bias"""						)
				if "stages" in name:
								__a       :     int								=	name.replace("""stages"""			,    """encoder.stages"""						)
				if "norm" in name:
								__a       :     Union[str, Any]								=	name.replace("""norm"""			,    """layernorm"""						)
				if "head" in name:
								__a       :     Optional[int]								=	name.replace("""head"""			,    """classifier"""						)

				return name

def 				_snake_case (		)       ->       List[str]:
				__a       :     List[Any]								=	"""http://images.cocodataset.org/val2017/000000039769.jpg"""
				__a       :     int								=	Image.open(requests.get(lowercase			,    stream=lowercase						).raw						)
				return im

def 				_snake_case (		lowercase						)       ->       Dict:
				if "224" in checkpoint_url:
								__a       :     List[Any]								=	2_2_4
								__a       :     Optional[Any]								=	2_2_4 / 2_5_6
				elif "384" in checkpoint_url:
								__a       :     List[str]								=	3_8_4
								__a       :     int								=	None
				else:
								__a       :     str								=	5_1_2
								__a       :     Tuple								=	None

				return ConvNextImageProcessor(
				    size=lowercase			,    crop_pct=lowercase			,    image_mean=[0.4_8_5, 0.4_5_6, 0.4_0_6]			,    image_std=[0.2_2_9, 0.2_2_4, 0.2_2_5]			,    resample=PILImageResampling.BICUBIC			,    )

@torch.no_grad()
def 				_snake_case (		lowercase			,    lowercase			,    lowercase			,    lowercase						)       ->       List[Any]:
				print("""Downloading original model from checkpoint..."""						)
				# define ConvNeXTV2 configuration based on URL
				__a							,	__a       :     Dict								=	get_convnextva_config(lowercase						)
				# load original state_dict from URL
				__a       :     str								=	torch.hub.load_state_dict_from_url(lowercase						)["""model"""]

				print("""Converting model parameters..."""						)
				# rename keys
				for key in state_dict.copy().keys():
								__a       :     Optional[int]								=	state_dict.pop(lowercase						)
								__a       :     List[Any]								=	val
				# add prefix to all keys expect classifier head
				for key in state_dict.copy().keys():
								__a       :     List[str]								=	state_dict.pop(lowercase						)
								if not key.startswith("""classifier"""						):
												__a       :     List[str]								=	"""convnextv2.""" + key
								__a       :     Tuple								=	val

				# load HuggingFace model
				__a       :     int								=	ConvNextVaForImageClassification(lowercase						)
				model.load_state_dict(lowercase						)
				model.eval()

				# Check outputs on an image, prepared by ConvNextImageProcessor
				__a       :     Union[str, Any]								=	convert_preprocessor(lowercase						)
				__a       :     List[Any]								=	preprocessor(images=prepare_img()			,    return_tensors="""pt"""						)
				__a       :     Union[str, Any]								=	model(**lowercase						).logits

				# note: the logits below were obtained without center cropping
				if checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnextv2/im1k/convnextv2_atto_1k_224_ema.pt":
								__a       :     List[str]								=	torch.tensor([-0.3_9_3_0, 0.1_7_4_7, -0.5_2_4_6, 0.4_1_7_7, 0.4_2_9_5]						)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnextv2/im1k/convnextv2_femto_1k_224_ema.pt":
								__a       :     Dict								=	torch.tensor([-0.1_7_2_7, -0.5_3_4_1, -0.7_8_1_8, -0.4_7_4_5, -0.6_5_6_6]						)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnextv2/im1k/convnextv2_pico_1k_224_ema.pt":
								__a       :     List[Any]								=	torch.tensor([-0.0_3_3_3, 0.1_5_6_3, -0.9_1_3_7, 0.1_0_5_4, 0.0_3_8_1]						)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnextv2/im1k/convnextv2_nano_1k_224_ema.pt":
								__a       :     List[str]								=	torch.tensor([-0.1_7_4_4, -0.1_5_5_5, -0.0_7_1_3, 0.0_9_5_0, -0.1_4_3_1]						)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnextv2/im1k/convnextv2_tiny_1k_224_ema.pt":
								__a       :     str								=	torch.tensor([0.9_9_9_6, 0.1_9_6_6, -0.4_3_8_6, -0.3_4_7_2, 0.6_6_6_1]						)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnextv2/im1k/convnextv2_base_1k_224_ema.pt":
								__a       :     Union[str, Any]								=	torch.tensor([-0.2_5_5_3, -0.6_7_0_8, -0.1_3_5_9, 0.2_5_1_8, -0.2_4_8_8]						)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnextv2/im1k/convnextv2_large_1k_224_ema.pt":
								__a       :     Union[str, Any]								=	torch.tensor([-0.0_6_7_3, -0.5_6_2_7, -0.3_7_5_3, -0.2_7_2_2, 0.0_1_7_8]						)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnextv2/im1k/convnextv2_huge_1k_224_ema.pt":
								__a       :     Union[str, Any]								=	torch.tensor([-0.6_3_7_7, -0.7_4_5_8, -0.2_1_5_0, 0.1_1_8_4, -0.0_5_9_7]						)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnextv2/im22k/convnextv2_nano_22k_224_ema.pt":
								__a       :     List[Any]								=	torch.tensor([1.0_7_9_9, 0.2_3_2_2, -0.8_8_6_0, 1.0_2_1_9, 0.6_2_3_1]						)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnextv2/im22k/convnextv2_nano_22k_384_ema.pt":
								__a       :     Optional[int]								=	torch.tensor([0.3_7_6_6, 0.4_9_1_7, -1.1_4_2_6, 0.9_9_4_2, 0.6_0_2_4]						)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnextv2/im22k/convnextv2_tiny_22k_224_ema.pt":
								__a       :     List[Any]								=	torch.tensor([0.4_2_2_0, -0.6_9_1_9, -0.4_3_1_7, -0.2_8_8_1, -0.6_6_0_9]						)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnextv2/im22k/convnextv2_tiny_22k_384_ema.pt":
								__a       :     Any								=	torch.tensor([0.1_0_8_2, -0.8_2_8_6, -0.5_0_9_5, 0.4_6_8_1, -0.8_0_8_5]						)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnextv2/im22k/convnextv2_base_22k_224_ema.pt":
								__a       :     List[Any]								=	torch.tensor([-0.2_4_1_9, -0.6_2_2_1, 0.2_1_7_6, -0.0_9_8_0, -0.7_5_2_7]						)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnextv2/im22k/convnextv2_base_22k_384_ema.pt":
								__a       :     int								=	torch.tensor([0.0_3_9_1, -0.4_3_7_1, 0.3_7_8_6, 0.1_2_5_1, -0.2_7_8_4]						)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnextv2/im22k/convnextv2_large_22k_224_ema.pt":
								__a       :     Optional[Any]								=	torch.tensor([-0.0_5_0_4, 0.5_6_3_6, -0.1_7_2_9, -0.6_5_0_7, -0.3_9_4_9]						)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnextv2/im22k/convnextv2_large_22k_384_ema.pt":
								__a       :     List[Any]								=	torch.tensor([0.3_5_6_0, 0.9_4_8_6, 0.3_1_4_9, -0.2_6_6_7, -0.5_1_3_8]						)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnextv2/im22k/convnextv2_huge_22k_384_ema.pt":
								__a       :     Any								=	torch.tensor([-0.2_4_6_9, -0.4_5_5_0, -0.5_8_5_3, -0.0_8_1_0, 0.0_3_0_9]						)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnextv2/im22k/convnextv2_huge_22k_512_ema.pt":
								__a       :     Optional[Any]								=	torch.tensor([-0.3_0_9_0, 0.0_8_0_2, -0.0_6_8_2, -0.1_9_7_9, -0.2_8_2_6]						)
				else:
								raise ValueError(F"""Unknown URL: {checkpoint_url}"""						)

				assert torch.allclose(logits[0, :5]			,    lowercase			,    atol=1E-3						)
				assert logits.shape == expected_shape
				print("""Model outputs match the original results!"""						)

				if save_model:
								print("""Saving model to local..."""						)
								# Create folder to save model
								if not os.path.isdir(lowercase						):
												os.mkdir(lowercase						)

								model.save_pretrained(lowercase						)
								preprocessor.save_pretrained(lowercase						)

				__a       :     int								=	"""convnextv2"""
				if "atto" in checkpoint_url:
								model_name += "-atto"
				if "femto" in checkpoint_url:
								model_name += "-femto"
				if "pico" in checkpoint_url:
								model_name += "-pico"
				if "nano" in checkpoint_url:
								model_name += "-nano"
				elif "tiny" in checkpoint_url:
								model_name += "-tiny"
				elif "base" in checkpoint_url:
								model_name += "-base"
				elif "large" in checkpoint_url:
								model_name += "-large"
				elif "huge" in checkpoint_url:
								model_name += "-huge"
				if "22k" in checkpoint_url and "1k" not in checkpoint_url:
								model_name += "-22k"
				elif "22k" in checkpoint_url and "1k" in checkpoint_url:
								model_name += "-22k-1k"
				elif "1k" in checkpoint_url:
								model_name += "-1k"
				if "224" in checkpoint_url:
								model_name += "-224"
				elif "384" in checkpoint_url:
								model_name += "-384"
				elif "512" in checkpoint_url:
								model_name += "-512"

				if push_to_hub:
								print(F"""Pushing {model_name} to the hub..."""						)
								model.push_to_hub(lowercase						)
								preprocessor.push_to_hub(lowercase						)


if __name__ == "__main__":
					__SCREAMING_SNAKE_CASE		:  str        =      argparse.ArgumentParser()
					# Required parameters
					parser.add_argument(
					    '--checkpoint_url',
					    default='https://dl.fbaipublicfiles.com/convnext/convnextv2/im1k/convnextv2_atto_1k_224_ema.pt',
					    type=str,
					    help='URL of the original ConvNeXTV2 checkpoint you\'d like to convert.',
					)
					parser.add_argument(
					    '--pytorch_dump_folder_path',
					    default='model',
					    type=str,
					    help='Path to the output PyTorch model directory.',
					)
					parser.add_argument('--save_model', action='store_true', help='Save model to local')
					parser.add_argument('--push_to_hub', action='store_true', help='Push model and image preprocessor to the hub')

					__SCREAMING_SNAKE_CASE		:  str        =      parser.parse_args()
					convert_convnextva_checkpoint(
					    args.checkpoint_url, args.pytorch_dump_folder_path, args.save_model, args.push_to_hub
					)

'''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"""],
					    )  ,    )