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      __SCREAMING_SNAKE_CASE		(		lowercase__    ,							lowercase__=10    ,							lowercase__=10    ,							lowercase__=False    ,							lowercase__=False   ):
  					"""simple docstring"""
  					A    =      []
  					for i in range(image_processor_tester.num_frames   ):
  										video.append(np.random.randint(255    ,							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    =      [Image.fromarray(np.moveaxis(lowercase__    ,							0    ,							-1   )   ) for frame in video]
  
  					if torchify:
  										A    =      [torch.from_numpy(lowercase__   ) for frame in video]
  
  					return video
  def      __SCREAMING_SNAKE_CASE		(		lowercase__    ,							lowercase__=False    ,							lowercase__=False    ,							lowercase__=False   ):
  					"""simple docstring"""
  					assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"
  
  					A    =      []
  					for i in range(image_processor_tester.batch_size   ):
  										if equal_resolution:
  															A    =      A    =      image_processor_tester.max_resolution
  										else:
  															A    ,					A    =      np.random.choice(
  															    np.arange(image_processor_tester.min_resolution    ,							image_processor_tester.max_resolution   )    ,							2   )
  															A    =      prepare_video(
  															    image_processor_tester=lowercase__    ,							width=lowercase__    ,							height=lowercase__    ,							numpify=lowercase__    ,							torchify=lowercase__    ,							)
  										video_inputs.append(lowercase__   )
  
  					return video_inputs
  
  
  
  
  
  class     __UpperCamelCase				(     unittest.TestCase		):
  
  
  		def __init__(self				:	Any  ,  __SCREAMING_SNAKE_CASE				:	str  ,  __SCREAMING_SNAKE_CASE				:	int=7  ,  __SCREAMING_SNAKE_CASE				:	List[str]=3  ,  __SCREAMING_SNAKE_CASE				:	Any=4  ,  __SCREAMING_SNAKE_CASE				:	str=1_8  ,  __SCREAMING_SNAKE_CASE				:	Optional[Any]=3_0  ,  __SCREAMING_SNAKE_CASE				:	Union[str, Any]=4_0_0  ,  __SCREAMING_SNAKE_CASE				:	Any=True  ,  __SCREAMING_SNAKE_CASE				:	List[Any]=None  ,  __SCREAMING_SNAKE_CASE				:	Union[str, Any]=True  ,  __SCREAMING_SNAKE_CASE				:	Optional[int]=[0.5, 0.5, 0.5]  ,  __SCREAMING_SNAKE_CASE				:	List[Any]=[0.5, 0.5, 0.5]  ,  __SCREAMING_SNAKE_CASE				:	Optional[Any]=True  ,  __SCREAMING_SNAKE_CASE				:	List[str]=None  ,  ):
  							A    =      size if size is not None else {"shortest_edge": 1_8}
  							A    =      crop_size if crop_size is not None else {"height": 1_8, "width": 1_8}
  
  							A    =      parent
  							A    =      batch_size
  							A    =      num_channels
  							A    =      num_frames
  							A    =      image_size
  							A    =      min_resolution
  							A    =      max_resolution
  							A    =      do_resize
  							A    =      size
  							A    =      do_normalize
  							A    =      image_mean
  							A    =      image_std
  							A    =      do_center_crop
  							A    =      crop_size
  
  
  		def       SCREAMING_SNAKE_CASE__     (self				:	List[str]):
  							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				(     _A  ,	unittest.TestCase		):
  		SCREAMING_SNAKE_CASE              =					TvltImageProcessor if is_vision_available() else None
  
  
  		def       SCREAMING_SNAKE_CASE__     (self				:	Dict):
  							A    =      TvltImageProcessorTester(self)
  
  
  		@property
  		def       SCREAMING_SNAKE_CASE__     (self				:	Dict):
  							return self.image_processor_tester.prepare_image_processor_dict()
  
  
  		def       SCREAMING_SNAKE_CASE__     (self				:	Any):
  							A    =      self.image_processing_class(**self.image_processor_dict)
  							self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE  ,  "image_mean"))
  							self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE  ,  "image_std"))
  							self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE  ,  "do_normalize"))
  							self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE  ,  "do_resize"))
  							self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE  ,  "do_center_crop"))
  							self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE  ,  "size"))
  
  
  		def       SCREAMING_SNAKE_CASE__     (self				:	str):
  							# Initialize image_processor
  							A    =      self.image_processing_class(**self.image_processor_dict)
  							# create random PIL videos
  							A    =      prepare_video_inputs(self.image_processor_tester  ,  equal_resolution=__SCREAMING_SNAKE_CASE)
  							for video in video_inputs:
  												self.assertIsInstance(__SCREAMING_SNAKE_CASE  ,  __SCREAMING_SNAKE_CASE)
  												self.assertIsInstance(video[0]  ,  Image.Image)
  
  							# Test not batched input
  							A    =      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    =      image_processor(__SCREAMING_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				:	Union[str, Any]):
  							# Initialize image_processor
  							A    =      self.image_processing_class(**self.image_processor_dict)
  							# create random numpy tensors
  							A    =      prepare_video_inputs(self.image_processor_tester  ,  equal_resolution=__SCREAMING_SNAKE_CASE  ,  numpify=__SCREAMING_SNAKE_CASE)
  							for video in video_inputs:
  												self.assertIsInstance(__SCREAMING_SNAKE_CASE  ,  __SCREAMING_SNAKE_CASE)
  												self.assertIsInstance(video[0]  ,  np.ndarray)
  
  							# Test not batched input
  							A    =      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    =      image_processor(__SCREAMING_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				:	Optional[int]):
  							# Initialize image_processor
  							A    =      self.image_processing_class(**self.image_processor_dict)
  							# create random PyTorch tensors
  							A    =      prepare_video_inputs(self.image_processor_tester  ,  equal_resolution=__SCREAMING_SNAKE_CASE  ,  torchify=__SCREAMING_SNAKE_CASE)
  							for video in video_inputs:
  												self.assertIsInstance(__SCREAMING_SNAKE_CASE  ,  __SCREAMING_SNAKE_CASE)
  												self.assertIsInstance(video[0]  ,  torch.Tensor)
  
  							# Test not batched input
  							A    =      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    =      image_processor(__SCREAMING_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"],
  							    )  ,  )
  
  
  
  
  
  
style_context: 
  
  """simple docstring"""
  
  
  
  
  def      __SCREAMING_SNAKE_CASE		(		lowercase__    ,							lowercase__   ):
  					"""simple docstring"""
  					A    =      1
  					while b > 0:
  										if b & 1:
  															res *= a
  
  										a *= a
  										b >>= 1
  
  					return res
  def      __SCREAMING_SNAKE_CASE		(		lowercase__    ,							lowercase__    ,							lowercase__   ):
  					"""simple docstring"""
  					A    =      1
  					while b > 0:
  										if b & 1:
  															A    =      ((res % c) * (a % c)) % c
  
  										a *= a
  										b >>= 1
  
  					return res
  
  
  
  
  
  