

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_video_inputs


if is_torch_available():
  import torch

if is_vision_available():
  from PIL import Image

  from transformers import VideoMAEImageProcessor






class 				A_					(						unittest.TestCase   ):


     def __init__(				self     :						List[Any]     ,    UpperCAmelCase     :						Dict     ,    UpperCAmelCase     :						List[str]=7     ,    UpperCAmelCase     :						Optional[int]=3     ,    UpperCAmelCase     :						List[Any]=1_0     ,    UpperCAmelCase     :						Optional[int]=1_8     ,    UpperCAmelCase     :						Dict=3_0     ,    UpperCAmelCase     :						Optional[Any]=4_0_0     ,    UpperCAmelCase     :						Optional[int]=True     ,    UpperCAmelCase     :						Tuple=None     ,    UpperCAmelCase     :						Tuple=True     ,    UpperCAmelCase     :						List[str]=[0.5, 0.5, 0.5]     ,    UpperCAmelCase     :						int=[0.5, 0.5, 0.5]     ,    UpperCAmelCase     :						Optional[int]=None     ,    )				->      Any:
      __lowerCAmelCase:  int        = size if size is not None else {'shortest_edge': 1_8}
      __lowerCAmelCase:  List[Any]        = crop_size if crop_size is not None else {'height': 1_8, 'width': 1_8}

      __lowerCAmelCase:  List[str]        = parent
      __lowerCAmelCase:  Union[str, Any]        = batch_size
      __lowerCAmelCase:  Union[str, Any]        = num_channels
      __lowerCAmelCase:  Union[str, Any]        = num_frames
      __lowerCAmelCase:  Optional[Any]        = image_size
      __lowerCAmelCase:  List[Any]        = min_resolution
      __lowerCAmelCase:  Dict        = max_resolution
      __lowerCAmelCase:  int        = do_resize
      __lowerCAmelCase:  Optional[Any]        = size
      __lowerCAmelCase:  Dict        = do_normalize
      __lowerCAmelCase:  Optional[Any]        = image_mean
      __lowerCAmelCase:  Tuple        = image_std
      __lowerCAmelCase:  List[str]        = crop_size


     def     UpperCAmelCase    (				self     :						Any   )				->      Union[str, 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,
          "crop_size": self.crop_size,
      }







@require_torch
@require_vision
class 				A_					(						snake_case__				,      unittest.TestCase   ):
     _lowercase     :	Union[str, Any]        =      VideoMAEImageProcessor if is_vision_available() else None


     def     UpperCAmelCase    (				self     :						List[Any]   )				->      Optional[Any]:
      __lowerCAmelCase:  List[str]        = VideoMAEImageProcessingTester(self   )


     @property
     def     UpperCAmelCase    (				self     :						Any   )				->      Tuple:
      return self.image_processor_tester.prepare_image_processor_dict()


     def     UpperCAmelCase    (				self     :						str   )				->      Any:
      __lowerCAmelCase:  Union[str, 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     UpperCAmelCase    (				self     :						Union[str, Any]   )				->      Optional[int]:
      __lowerCAmelCase:  Any        = self.image_processing_class.from_dict(self.image_processor_dict   )
      self.assertEqual(image_processor.size     ,    {'shortest_edge': 1_8}   )
      self.assertEqual(image_processor.crop_size     ,    {'height': 1_8, 'width': 1_8}   )

      __lowerCAmelCase:  int        = self.image_processing_class.from_dict(self.image_processor_dict     ,    size=4_2     ,    crop_size=8_4   )
      self.assertEqual(image_processor.size     ,    {'shortest_edge': 4_2}   )
      self.assertEqual(image_processor.crop_size     ,    {'height': 8_4, 'width': 8_4}   )


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


     def     UpperCAmelCase    (				self     :						List[str]   )				->      Optional[int]:
      # Initialize image_processing
      __lowerCAmelCase:  List[Any]        = self.image_processing_class(**self.image_processor_dict   )
      # create random PIL videos
      __lowerCAmelCase:  List[Any]        = 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
      __lowerCAmelCase:  Optional[Any]        = image_processing(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
      __lowerCAmelCase:  Any        = image_processing(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     UpperCAmelCase    (				self     :						Optional[Any]   )				->      str:
      # Initialize image_processing
      __lowerCAmelCase:  Tuple        = self.image_processing_class(**self.image_processor_dict   )
      # create random numpy tensors
      __lowerCAmelCase:  Dict        = 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
      __lowerCAmelCase:  str        = image_processing(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
      __lowerCAmelCase:  List[str]        = image_processing(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     UpperCAmelCase    (				self     :						Union[str, Any]   )				->      Dict:
      # Initialize image_processing
      __lowerCAmelCase:  Union[str, Any]        = self.image_processing_class(**self.image_processor_dict   )
      # create random PyTorch tensors
      __lowerCAmelCase:  List[str]        = 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
      __lowerCAmelCase:  Dict        = image_processing(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
      __lowerCAmelCase:  Optional[Any]        = image_processing(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 _a					(			SCREAMING_SNAKE_CASE						:     int						)       ->       int:

 """simple docstring"""






 return n * (2 * n - 1)







def _a					(			SCREAMING_SNAKE_CASE						:     int						)       ->       bool:

 """simple docstring"""






 __lowerCAmelCase:  List[Any]        = (1 + 24 * n) ** 0.5
 return ((1 + root) / 6) % 1 == 0







def _a					(			SCREAMING_SNAKE_CASE						:     int = 1_44						)       ->       int:

 """simple docstring"""






 __lowerCAmelCase:  Dict        = start
 __lowerCAmelCase:  List[str]        = hexagonal_num(SCREAMING_SNAKE_CASE						)
 while not is_pentagonal(SCREAMING_SNAKE_CASE						):
  n += 1
  __lowerCAmelCase:  Any        = hexagonal_num(SCREAMING_SNAKE_CASE						)
 return num


if __name__ == "__main__":
  print(f"{solution()} = ")





