




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 BlipImageProcessor

class   UpperCAmelCase    (      unittest.TestCase ):






   def __init__(						self :							Tuple    ,       UpperCamelCase_ :							List[Any]    ,       UpperCamelCase_ :							Optional[Any]=7    ,       UpperCamelCase_ :							Union[str, Any]=3    ,       UpperCamelCase_ :							Dict=18    ,       UpperCamelCase_ :							Optional[Any]=30    ,       UpperCamelCase_ :							Tuple=4_00    ,       UpperCamelCase_ :							Tuple=True    ,       UpperCamelCase_ :							Any=None    ,       UpperCamelCase_ :							Tuple=True    ,       UpperCamelCase_ :							Any=False    ,       UpperCamelCase_ :							Dict=[0.48_145_466, 0.4_578_275, 0.40_821_073]    ,       UpperCamelCase_ :							Optional[int]=[0.26_862_954, 0.26_130_258, 0.27_577_711]    ,       UpperCamelCase_ :							Dict=True    ,       )->      List[Any]:
     _lowercase:			Any      =     size if size is not None else {'height': 20, 'width': 20}
     _lowercase:			Tuple      =     parent
     _lowercase:			List[str]      =     batch_size
     _lowercase:			Optional[Any]      =     num_channels
     _lowercase:			Optional[Any]      =     image_size
     _lowercase:			int      =     min_resolution
     _lowercase:			int      =     max_resolution
     _lowercase:			Tuple      =     do_resize
     _lowercase:			Any      =     size
     _lowercase:			Union[str, Any]      =     do_normalize
     _lowercase:			Optional[Any]      =     image_mean
     _lowercase:			int      =     image_std
     _lowercase:			List[Any]      =     do_pad
     _lowercase:			str      =     do_convert_rgb






   def 			_a    (						self :							Optional[Any]  )->      Union[str, Any]:
     return {
         "do_resize": self.do_resize,
         "size": self.size,
         "do_normalize": self.do_normalize,
         "image_mean": self.image_mean,
         "image_std": self.image_std,
         "do_convert_rgb": self.do_convert_rgb,
         "do_pad": self.do_pad,
     }






   def 			_a    (						self :							Union[str, Any]    ,       UpperCamelCase_ :							Tuple=False    ,       UpperCamelCase_ :							List[Any]=False    ,       UpperCamelCase_ :							List[Any]=False  )->      List[Any]:
     assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

     if equal_resolution:
       _lowercase:			List[Any]      =     []
       for i in range(self.batch_size  ):
         image_inputs.append(
             np.random.randint(
                 2_55    ,       size=(self.num_channels, self.max_resolution, self.max_resolution)    ,       dtype=np.uinta  )  )
     else:
       _lowercase:			str      =     []
       for i in range(self.batch_size  ):
         _lowercase:			Tuple      =     np.random.choice(np.arange(self.min_resolution    ,       self.max_resolution  )    ,       2  )
         image_inputs.append(np.random.randint(2_55    ,       size=(self.num_channels, width, height)    ,       dtype=np.uinta  )  )

     if not numpify and not torchify:
       # PIL expects the channel dimension as last dimension
       _lowercase:			Optional[int]      =     [Image.fromarray(np.moveaxis(UpperCamelCase_    ,       0    ,       -1  )  ) for x in image_inputs]

     if torchify:
       _lowercase:			Any      =     [torch.from_numpy(UpperCamelCase_  ) for x in image_inputs]

     return image_inputs

@require_torch
@require_vision
class   UpperCAmelCase    (      a_ ,       unittest.TestCase ):
   __SCREAMING_SNAKE_CASE		:				Tuple      					=       BlipImageProcessor if is_vision_available() else None






   def 			_a    (						self :							List[Any]  )->      List[str]:
     _lowercase:			Dict      =     BlipImageProcessingTester(self  )






   @property
   def 			_a    (						self :							int  )->      str:
     return self.image_processor_tester.prepare_image_processor_dict()






   def 			_a    (						self :							Tuple  )->      Optional[int]:
     _lowercase:			Any      =     self.image_processing_class(**self.image_processor_dict  )
     self.assertTrue(hasattr(UpperCamelCase_    ,       'do_resize'  )  )
     self.assertTrue(hasattr(UpperCamelCase_    ,       'size'  )  )
     self.assertTrue(hasattr(UpperCamelCase_    ,       'do_normalize'  )  )
     self.assertTrue(hasattr(UpperCamelCase_    ,       'image_mean'  )  )
     self.assertTrue(hasattr(UpperCamelCase_    ,       'image_std'  )  )
     self.assertTrue(hasattr(UpperCamelCase_    ,       'do_convert_rgb'  )  )






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






   def 			_a    (						self :							Optional[int]  )->      Optional[Any]:
     # Initialize image_processor
     _lowercase:			int      =     self.image_processing_class(**self.image_processor_dict  )
     # create random PIL images
     _lowercase:			Union[str, Any]      =     self.image_processor_tester.prepare_inputs(equal_resolution=UpperCamelCase_  )
     for image in image_inputs:
       self.assertIsInstance(UpperCamelCase_    ,       Image.Image  )

     # Test not batched input
     _lowercase:			Union[str, Any]      =     image_processor(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
     _lowercase:			List[Any]      =     image_processor(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    (						self :							str  )->      Union[str, Any]:
     # Initialize image_processor
     _lowercase:			Optional[int]      =     self.image_processing_class(**self.image_processor_dict  )
     # create random numpy tensors
     _lowercase:			List[Any]      =     self.image_processor_tester.prepare_inputs(equal_resolution=UpperCamelCase_    ,       numpify=UpperCamelCase_  )
     for image in image_inputs:
       self.assertIsInstance(UpperCamelCase_    ,       np.ndarray  )

     # Test not batched input
     _lowercase:			str      =     image_processor(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
     _lowercase:			Tuple      =     image_processor(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    (						self :							str  )->      List[str]:
     # Initialize image_processor
     _lowercase:			Optional[Any]      =     self.image_processing_class(**self.image_processor_dict  )
     # create random PyTorch tensors
     _lowercase:			int      =     self.image_processor_tester.prepare_inputs(equal_resolution=UpperCamelCase_    ,       torchify=UpperCamelCase_  )
     for image in image_inputs:
       self.assertIsInstance(UpperCamelCase_    ,       torch.Tensor  )

     # Test not batched input
     _lowercase:			Optional[int]      =     image_processor(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
     _lowercase:			Any      =     image_processor(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'],
         )    ,       )

@require_torch
@require_vision
class   UpperCAmelCase    (      a_ ,       unittest.TestCase ):
   __SCREAMING_SNAKE_CASE		:				Optional[Any]      					=       BlipImageProcessor if is_vision_available() else None






   def 			_a    (						self :							Tuple  )->      Optional[int]:
     _lowercase:			Any      =     BlipImageProcessingTester(self    ,       num_channels=4  )
     _lowercase:			Tuple      =     3






   @property
   def 			_a    (						self :							Union[str, Any]  )->      int:
     return self.image_processor_tester.prepare_image_processor_dict()






   def 			_a    (						self :							Optional[int]  )->      Optional[Any]:
     _lowercase:			Dict      =     self.image_processing_class(**self.image_processor_dict  )
     self.assertTrue(hasattr(UpperCamelCase_    ,       'do_resize'  )  )
     self.assertTrue(hasattr(UpperCamelCase_    ,       'size'  )  )
     self.assertTrue(hasattr(UpperCamelCase_    ,       'do_normalize'  )  )
     self.assertTrue(hasattr(UpperCamelCase_    ,       'image_mean'  )  )
     self.assertTrue(hasattr(UpperCamelCase_    ,       'image_std'  )  )
     self.assertTrue(hasattr(UpperCamelCase_    ,       'do_convert_rgb'  )  )






   def 			_a    (						self :							Tuple  )->      Any:
     pass






   def 			_a    (						self :							Optional[int]  )->      Union[str, Any]:
     # Initialize image_processor
     _lowercase:			Any      =     self.image_processing_class(**self.image_processor_dict  )
     # create random PIL images
     _lowercase:			str      =     self.image_processor_tester.prepare_inputs(equal_resolution=UpperCamelCase_  )
     for image in image_inputs:
       self.assertIsInstance(UpperCamelCase_    ,       Image.Image  )

     # Test not batched input
     _lowercase:			int      =     image_processor(image_inputs[0]    ,       return_tensors='pt'  ).pixel_values
     self.assertEqual(
         encoded_images.shape    ,       (
             1,
             self.expected_encoded_image_num_channels,
             self.image_processor_tester.size['height'],
             self.image_processor_tester.size['width'],
         )    ,       )

     # Test batched
     _lowercase:			List[str]      =     image_processor(UpperCamelCase_    ,       return_tensors='pt'  ).pixel_values
     self.assertEqual(
         encoded_images.shape    ,       (
             self.image_processor_tester.batch_size,
             self.expected_encoded_image_num_channels,
             self.image_processor_tester.size['height'],
             self.image_processor_tester.size['width'],
         )    ,       )

def SCREAMING_SNAKE_CASE					(  lowercase_:						int					):
       return n * (2 * n - 1)


def SCREAMING_SNAKE_CASE					(  lowercase_:						int					):
       _UpperCamelCase  :							str	    =	(1 + 24 * n) ** 0.5
       return ((1 + root) / 6) % 1 == 0


def SCREAMING_SNAKE_CASE					(  lowercase_:						int = 144					):
       _UpperCamelCase  :							Optional[Any]	    =	start
       _UpperCamelCase  :							List[str]	    =	hexagonal_num(lowercase_					)
       while not is_pentagonal(lowercase_					):
              n += 1
              _UpperCamelCase  :							Optional[int]	    =	hexagonal_num(lowercase_					)
       return num


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



