code: 
  
  
  
  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     UpperCAmelCase__ (							__snake_case						,				__snake_case=10						,				__snake_case=10						,				__snake_case=False						,				__snake_case=False							)   -> Union[str, Any]:
    _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(__snake_case						,				0						,				-1							)							) for frame in video]
  
    if torchify:
      _A           =    [torch.from_numpy(__snake_case							) for frame in video]
  
    return video
  
  
  
  
  def     UpperCAmelCase__ (							__snake_case						,				__snake_case=False						,				__snake_case=False						,				__snake_case=False							)   -> Union[str, Any]:
    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=__snake_case						,				width=__snake_case						,				height=__snake_case						,				numpify=__snake_case						,				torchify=__snake_case						,				)
      video_inputs.append(__snake_case							)
  
    return video_inputs
  
  
  
  class 		_snake_case      (			unittest.TestCase				):
  
  
  
  
  
   """simple docstring"""
  
  
  
   def __init__(						self	,    a	,    a=7	,    a=3	,    a=4	,    a=1_8	,    a=3_0	,    a=4_0_0	,    a=True	,    a=None	,    a=True	,    a=[0.5, 0.5, 0.5]	,    a=[0.5, 0.5, 0.5]	,    a=True	,    a=None	,    )	->							Dict:
  
  
  
  
     """simple docstring"""
  
  
  
  
  
  
  
     _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 lowercase_		(						self					)	->							int:
  
  
  
  
     """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 		_snake_case      (			lowerCamelCase					,unittest.TestCase				):
  
  
  
  
  
   """simple docstring"""
  
  
  
   lowerCamelCase_          =			TvltImageProcessor if is_vision_available() else None
   def lowercase_		(						self					)	->							Any:
  
  
  
  
     """simple docstring"""
  
  
  
  
  
  
  
     _A           =    TvltImageProcessorTester(self					)
   @property
   def lowercase_		(						self					)	->							Optional[int]:
  
  
  
  
     """simple docstring"""
  
  
  
  
  
  
  
     return self.image_processor_tester.prepare_image_processor_dict()
   def lowercase_		(						self					)	->							Optional[Any]:
  
  
  
  
     """simple docstring"""
  
  
  
  
  
  
  
     _A           =    self.image_processing_class(**self.image_processor_dict					)
     self.assertTrue(hasattr(a	,    '''image_mean'''					)					)
     self.assertTrue(hasattr(a	,    '''image_std'''					)					)
     self.assertTrue(hasattr(a	,    '''do_normalize'''					)					)
     self.assertTrue(hasattr(a	,    '''do_resize'''					)					)
     self.assertTrue(hasattr(a	,    '''do_center_crop'''					)					)
     self.assertTrue(hasattr(a	,    '''size'''					)					)
   def lowercase_		(						self					)	->							List[Any]:
  
  
  
  
     """simple docstring"""
  
  
  
  
  
  
  
     _A           =    self.image_processing_class(**self.image_processor_dict					)
     # create random PIL videos
     _A           =    prepare_video_inputs(self.image_processor_tester	,    equal_resolution=a					)
     for video in video_inputs:
       self.assertIsInstance(a	,    a					)
       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(a	,    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					)	->							Optional[int]:
  
  
  
  
     """simple docstring"""
  
  
  
  
  
  
  
     _A           =    self.image_processing_class(**self.image_processor_dict					)
     # create random numpy tensors
     _A           =    prepare_video_inputs(self.image_processor_tester	,    equal_resolution=a	,    numpify=a					)
     for video in video_inputs:
       self.assertIsInstance(a	,    a					)
       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(a	,    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:
  
  
  
  
     """simple docstring"""
  
  
  
  
  
  
  
     _A           =    self.image_processing_class(**self.image_processor_dict					)
     # create random PyTorch tensors
     _A           =    prepare_video_inputs(self.image_processor_tester	,    equal_resolution=a	,    torchify=a					)
     for video in video_inputs:
       self.assertIsInstance(a	,    a					)
       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(a	,    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: 
  
  
  
  import platform
  from argparse import ArgumentParser
  
  import huggingface_hub
  import pandas
  import pyarrow
  
  from datasets import __version__ as version
  from datasets.commands import BaseDatasetsCLICommand
  
  
  
  
  def     UpperCAmelCase__ (							__snake_case							)   -> Optional[Any]:
    return EnvironmentCommand()
  
  
  
  class 		_snake_case      (			lowerCamelCase				):
  
  
  
  
  
   """simple docstring"""
  
  
  
   @staticmethod
   def lowercase_		(						a					)	->							Dict:
  
  
  
  
     """simple docstring"""
  
  
  
  
  
  
  
     _A           =    parser.add_parser('''env'''	,    help='''Print relevant system environment info.'''					)
     download_parser.set_defaults(func=a					)
   def lowercase_		(						self					)	->							Optional[int]:
  
  
  
  
     """simple docstring"""
  
  
  
  
  
  
  
     _A           =    {
         '''`datasets` version''': version,
         '''Platform''': platform.platform(),
         '''Python version''': platform.python_version(),
         '''Huggingface_hub version''': huggingface_hub.__version__,
         '''PyArrow version''': pyarrow.__version__,
         '''Pandas version''': pandas.__version__,
     }
  
     print('''\nCopy-and-paste the text below in your GitHub issue.\n'''					)
     print(self.format_dict(a					)					)
  
     return info
  
  
  
   @staticmethod
   def lowercase_		(						a					)	->							Optional[int]:
  
  
  
  
     """simple docstring"""
  
  
  
  
  
  
  
     return "\n".join([f'''- {prop}: {val}''' for prop, val in d.items()]					) + "\n"