

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_image_inputs


if is_torch_available():
  import torch

if is_vision_available():
  from PIL import Image

  from transformers import ViTImageProcessor






class 				A_					(						unittest.TestCase   ):


     def __init__(				self     :						Union[str, Any]     ,    UpperCAmelCase     :						Optional[int]     ,    UpperCAmelCase     :						Any=7     ,    UpperCAmelCase     :						Optional[int]=3     ,    UpperCAmelCase     :						Union[str, Any]=1_8     ,    UpperCAmelCase     :						Tuple=3_0     ,    UpperCAmelCase     :						List[str]=4_0_0     ,    UpperCAmelCase     :						Any=True     ,    UpperCAmelCase     :						List[Any]=None     ,    UpperCAmelCase     :						List[Any]=True     ,    UpperCAmelCase     :						Any=[0.5, 0.5, 0.5]     ,    UpperCAmelCase     :						Optional[int]=[0.5, 0.5, 0.5]     ,    )				->      Union[str, Any]:
      __lowerCAmelCase:  Optional[int]        = size if size is not None else {'height': 1_8, 'width': 1_8}
      __lowerCAmelCase:  List[str]        = parent
      __lowerCAmelCase:  List[Any]        = batch_size
      __lowerCAmelCase:  Tuple        = num_channels
      __lowerCAmelCase:  Any        = image_size
      __lowerCAmelCase:  int        = min_resolution
      __lowerCAmelCase:  Dict        = max_resolution
      __lowerCAmelCase:  int        = do_resize
      __lowerCAmelCase:  str        = size
      __lowerCAmelCase:  Optional[int]        = do_normalize
      __lowerCAmelCase:  Tuple        = image_mean
      __lowerCAmelCase:  Optional[Any]        = image_std


     def     UpperCAmelCase    (				self     :						str   )				->      int:
      return {
          "image_mean": self.image_mean,
          "image_std": self.image_std,
          "do_normalize": self.do_normalize,
          "do_resize": self.do_resize,
          "size": self.size,
      }







@require_torch
@require_vision
class 				A_					(						snake_case__				,      unittest.TestCase   ):
     _lowercase     :	Tuple        =      ViTImageProcessor if is_vision_available() else None


     def     UpperCAmelCase    (				self     :						Optional[Any]   )				->      Optional[Any]:
      __lowerCAmelCase:  Tuple        = ViTImageProcessingTester(self   )


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


     def     UpperCAmelCase    (				self     :						Optional[Any]   )				->      Optional[Any]:
      __lowerCAmelCase:  str        = 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     ,    'size'   )   )


     def     UpperCAmelCase    (				self     :						List[str]   )				->      List[str]:
      __lowerCAmelCase:  Optional[int]        = self.image_processing_class.from_dict(self.image_processor_dict   )
      self.assertEqual(image_processor.size     ,    {'height': 1_8, 'width': 1_8}   )

      __lowerCAmelCase:  Any        = self.image_processing_class.from_dict(self.image_processor_dict     ,    size=4_2   )
      self.assertEqual(image_processor.size     ,    {'height': 4_2, 'width': 4_2}   )


     def     UpperCAmelCase    (				self     :						str   )				->      Optional[Any]:
      pass


     def     UpperCAmelCase    (				self     :						int   )				->      Any:
      # Initialize image_processing
      __lowerCAmelCase:  Tuple        = self.image_processing_class(**self.image_processor_dict   )
      # create random PIL images
      __lowerCAmelCase:  str        = prepare_image_inputs(self.image_processor_tester     ,    equal_resolution=UpperCAmelCase   )
      for image in image_inputs:
       self.assertIsInstance(UpperCAmelCase     ,    Image.Image   )

      # Test not batched input
      __lowerCAmelCase:  List[str]        = image_processing(image_inputs[0]     ,    return_tensors='pt'   ).pixel_values
      self.assertEqual(
          encoded_images.shape     ,    (
              1,
              self.image_processor_tester.num_channels,
              self.image_processor_tester.size['height'],
              self.image_processor_tester.size['width'],
          )     ,    )

      # Test batched
      __lowerCAmelCase:  int        = image_processing(UpperCAmelCase     ,    return_tensors='pt'   ).pixel_values
      self.assertEqual(
          encoded_images.shape     ,    (
              self.image_processor_tester.batch_size,
              self.image_processor_tester.num_channels,
              self.image_processor_tester.size['height'],
              self.image_processor_tester.size['width'],
          )     ,    )


     def     UpperCAmelCase    (				self     :						Optional[int]   )				->      Union[str, Any]:
      # Initialize image_processing
      __lowerCAmelCase:  Union[str, Any]        = self.image_processing_class(**self.image_processor_dict   )
      # create random numpy tensors
      __lowerCAmelCase:  int        = prepare_image_inputs(self.image_processor_tester     ,    equal_resolution=UpperCAmelCase     ,    numpify=UpperCAmelCase   )
      for image in image_inputs:
       self.assertIsInstance(UpperCAmelCase     ,    np.ndarray   )

      # Test not batched input
      __lowerCAmelCase:  List[Any]        = image_processing(image_inputs[0]     ,    return_tensors='pt'   ).pixel_values
      self.assertEqual(
          encoded_images.shape     ,    (
              1,
              self.image_processor_tester.num_channels,
              self.image_processor_tester.size['height'],
              self.image_processor_tester.size['width'],
          )     ,    )

      # Test batched
      __lowerCAmelCase:  List[str]        = image_processing(UpperCAmelCase     ,    return_tensors='pt'   ).pixel_values
      self.assertEqual(
          encoded_images.shape     ,    (
              self.image_processor_tester.batch_size,
              self.image_processor_tester.num_channels,
              self.image_processor_tester.size['height'],
              self.image_processor_tester.size['width'],
          )     ,    )


     def     UpperCAmelCase    (				self     :						Dict   )				->      Union[str, Any]:
      # Initialize image_processing
      __lowerCAmelCase:  str        = self.image_processing_class(**self.image_processor_dict   )
      # create random PyTorch tensors
      __lowerCAmelCase:  int        = prepare_image_inputs(self.image_processor_tester     ,    equal_resolution=UpperCAmelCase     ,    torchify=UpperCAmelCase   )
      for image in image_inputs:
       self.assertIsInstance(UpperCAmelCase     ,    torch.Tensor   )

      # Test not batched input
      __lowerCAmelCase:  Optional[Any]        = image_processing(image_inputs[0]     ,    return_tensors='pt'   ).pixel_values
      self.assertEqual(
          encoded_images.shape     ,    (
              1,
              self.image_processor_tester.num_channels,
              self.image_processor_tester.size['height'],
              self.image_processor_tester.size['width'],
          )     ,    )

      # Test batched
      __lowerCAmelCase:  Optional[int]        = image_processing(UpperCAmelCase     ,    return_tensors='pt'   ).pixel_values
      self.assertEqual(
          encoded_images.shape     ,    (
              self.image_processor_tester.batch_size,
              self.image_processor_tester.num_channels,
              self.image_processor_tester.size['height'],
              self.image_processor_tester.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()} = ")





