code: 
  '''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__	(      UpperCamelCase			,UpperCamelCase=10			,UpperCamelCase=10			,UpperCamelCase=False			,UpperCamelCase=False	) ->      List[Any]:
  		_UpperCamelCase       : Tuple    =      []
  		for i in range(image_processor_tester.num_frames	):
  				video.append(np.random.randint(2_55			,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
  				_UpperCamelCase       : List[Any]    =      [Image.fromarray(np.moveaxis(_A			,0			,-1	)	) for frame in video]
  
  		if torchify:
  				_UpperCamelCase       : Union[str, Any]    =      [torch.from_numpy(_A	) for frame in video]
  
  		return video
  
  
  
  
  
  
  
  def 						snake_case__	(      UpperCamelCase			,UpperCamelCase=False			,UpperCamelCase=False			,UpperCamelCase=False	) ->      str:
  		assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"
  
  		_UpperCamelCase       : List[str]    =      []
  		for i in range(image_processor_tester.batch_size	):
  				if equal_resolution:
  						_UpperCamelCase       : Optional[Any]    =      image_processor_tester.max_resolution
  				else:
  						_UpperCamelCase,							_UpperCamelCase       : List[str]    =      np.random.choice(
  						    np.arange(image_processor_tester.min_resolution			,image_processor_tester.max_resolution	)			,2	)
  						_UpperCamelCase       : List[Any]    =      prepare_video(
  						    image_processor_tester=_A			,width=_A			,height=_A			,numpify=_A			,torchify=_A			,)
  				video_inputs.append(_A	)
  
  		return video_inputs
  
  class 			UpperCAmelCase				(					unittest.TestCase ):
  
  
  
  
  
  		"""simple docstring"""
  
  
  
  
  
  		def __init__(    self  ,					_snake_case  ,					_snake_case=7  ,					_snake_case=3  ,					_snake_case=4  ,					_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=True  ,					_snake_case=None  ,					)				->    Optional[int]:
  				_UpperCamelCase       : List[Any]    =      size if size is not None else {'''shortest_edge''': 18}
  				_UpperCamelCase       : int    =      crop_size if crop_size is not None else {'''height''': 18, '''width''': 18}
  
  				_UpperCamelCase       : Union[str, Any]    =      parent
  				_UpperCamelCase       : str    =      batch_size
  				_UpperCamelCase       : Optional[int]    =      num_channels
  				_UpperCamelCase       : Tuple    =      num_frames
  				_UpperCamelCase       : Union[str, Any]    =      image_size
  				_UpperCamelCase       : Dict    =      min_resolution
  				_UpperCamelCase       : Dict    =      max_resolution
  				_UpperCamelCase       : List[Any]    =      do_resize
  				_UpperCamelCase       : Optional[Any]    =      size
  				_UpperCamelCase       : Dict    =      do_normalize
  				_UpperCamelCase       : Optional[int]    =      image_mean
  				_UpperCamelCase       : List[str]    =      image_std
  				_UpperCamelCase       : List[str]    =      do_center_crop
  				_UpperCamelCase       : int    =      crop_size
  
  
  
  
  		def _lowercase  (    self     )				->    Any:
  				return {
  				    "image_mean": self.image_mean,
  				    "image_std": self.image_std,
  				    "do_normalize": self.do_normalize,
  				    "do_resize": self.do_resize,
  				    "size": self.size,
  				    "do_center_crop": self.do_center_crop,
  				    "crop_size": self.crop_size,
  				}
  
  
  
  
  
  
  
  @require_torch
  @require_vision
  class 			UpperCAmelCase				(					lowerCamelCase__  ,		unittest.TestCase ):
  
  
  
  
  
  		"""simple docstring"""
  
  
  
  
  
  		A__  :   str          =    TvltImageProcessor if is_vision_available() else None
  		def _lowercase  (    self     )				->    Optional[Any]:
  				_UpperCamelCase       : List[str]    =      TvltImageProcessorTester(self     )
  		@property
  		def _lowercase  (    self     )				->    Optional[Any]:
  				return self.image_processor_tester.prepare_image_processor_dict()
  		def _lowercase  (    self     )				->    str:
  				_UpperCamelCase       : Optional[int]    =      self.image_processing_class(**self.image_processor_dict     )
  				self.assertTrue(hasattr(lowercase_  ,					'''image_mean'''     )     )
  				self.assertTrue(hasattr(lowercase_  ,					'''image_std'''     )     )
  				self.assertTrue(hasattr(lowercase_  ,					'''do_normalize'''     )     )
  				self.assertTrue(hasattr(lowercase_  ,					'''do_resize'''     )     )
  				self.assertTrue(hasattr(lowercase_  ,					'''do_center_crop'''     )     )
  				self.assertTrue(hasattr(lowercase_  ,					'''size'''     )     )
  		def _lowercase  (    self     )				->    Tuple:
  				_UpperCamelCase       : Any    =      self.image_processing_class(**self.image_processor_dict     )
  				# create random PIL videos
  				_UpperCamelCase       : int    =      prepare_video_inputs(self.image_processor_tester  ,					equal_resolution=lowercase_     )
  				for video in video_inputs:
  						self.assertIsInstance(lowercase_  ,					lowercase_     )
  						self.assertIsInstance(video[0]  ,					Image.Image     )
  
  				# Test not batched input
  				_UpperCamelCase       : 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
  				_UpperCamelCase       : Dict    =      image_processor(lowercase_  ,					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 _lowercase  (    self     )				->    int:
  				_UpperCamelCase       : Optional[Any]    =      self.image_processing_class(**self.image_processor_dict     )
  				# create random numpy tensors
  				_UpperCamelCase       : Tuple    =      prepare_video_inputs(self.image_processor_tester  ,					equal_resolution=lowercase_  ,					numpify=lowercase_     )
  				for video in video_inputs:
  						self.assertIsInstance(lowercase_  ,					lowercase_     )
  						self.assertIsInstance(video[0]  ,					np.ndarray     )
  
  				# Test not batched input
  				_UpperCamelCase       : Optional[Any]    =      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
  				_UpperCamelCase       : Any    =      image_processor(lowercase_  ,					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 _lowercase  (    self     )				->    int:
  				_UpperCamelCase       : Optional[int]    =      self.image_processing_class(**self.image_processor_dict     )
  				# create random PyTorch tensors
  				_UpperCamelCase       : Union[str, Any]    =      prepare_video_inputs(self.image_processor_tester  ,					equal_resolution=lowercase_  ,					torchify=lowercase_     )
  				for video in video_inputs:
  						self.assertIsInstance(lowercase_  ,					lowercase_     )
  						self.assertIsInstance(video[0]  ,					torch.Tensor     )
  
  				# Test not batched input
  				_UpperCamelCase       : Dict    =      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
  				_UpperCamelCase       : int    =      image_processor(lowercase_  ,					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'''],
  				    )  ,					)
  
  
  
  
  
style_context: 
  '''simple docstring'''
  
  import warnings
  
  from ...utils import logging
  from .image_processing_mobilenet_va import MobileNetVaImageProcessor
  
  
  _UpperCAmelCase   :      Optional[int] 						=  logging.get_logger(__name__)
  
  class 			UpperCAmelCase				(					a_ ):
  
  
  
  
  
  		"""simple docstring"""
  
  
  
  
  
  		def __init__(    self  ,					*_snake_case  ,					**_snake_case     )				->    None:
  				warnings.warn(
  				    '''The class MobileNetV2FeatureExtractor is deprecated and will be removed in version 5 of Transformers.'''
  				    ''' Please use MobileNetV2ImageProcessor instead.'''  ,					_snake_case  ,					)
  				super().__init__(*_snake_case  ,					**_snake_case     )
  
  
  
  
  
  