






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 		lowercase_					(	unittest.TestCase   ):






      '''simple docstring'''




      def __init__(      self      :						Dict ,					__UpperCAmelCase      :						Any ,					__UpperCAmelCase      :						List[str]=13 ,					__UpperCAmelCase      :						List[Any]=3 ,					__UpperCAmelCase      :						Tuple=224 ,					__UpperCAmelCase      :						Dict=30 ,					__UpperCAmelCase      :						Any=400 ,					__UpperCAmelCase      :						Any=True ,					__UpperCAmelCase      :						Any=None ,					__UpperCAmelCase      :						str=True ,					__UpperCAmelCase      :						Optional[int]=[0.5, 0.5, 0.5] ,					__UpperCAmelCase      :						Optional[Any]=[0.5, 0.5, 0.5] ,					)    ->Optional[int]:




       """simple docstring"""


       a		  =      size if size is not None else {'''height''': 18, '''width''': 18}
       a		  =      parent
       a		  =      batch_size
       a		  =      num_channels
       a		  =      image_size
       a		  =      min_resolution
       a		  =      max_resolution
       a		  =      do_resize
       a		  =      size
       a		  =      do_normalize
       a		  =      image_mean
       a		  =      image_std







      def       __lowerCAmelCase					(      self      :						Optional[int]  )    ->List[Any]:




       """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,
       }






@require_torch
@require_vision
class 		lowercase_					(	lowercase ,  unittest.TestCase   ):






      '''simple docstring'''




      __snake_case       =  ViTImageProcessor if is_vision_available() else None







      def       __lowerCAmelCase					(      self      :						List[str]  )    ->Tuple:




       """simple docstring"""


       a		  =      EfficientFormerImageProcessorTester(self  )







      @property
      def       __lowerCAmelCase					(      self      :						int  )    ->Optional[int]:




       """simple docstring"""


       return self.image_proc_tester.prepare_image_processor_dict()







      def       __lowerCAmelCase					(      self      :						Dict  )    ->Tuple:




       """simple docstring"""


       a		  =      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       __lowerCAmelCase					(      self      :						Tuple  )    ->int:




       """simple docstring"""


       pass







      def       __lowerCAmelCase					(      self      :						List[str]  )    ->Optional[int]:




       """simple docstring"""


       a		  =      self.image_processing_class(**self.image_processor_dict  )
       # create random PIL images
       a		  =      prepare_image_inputs(self.image_proc_tester ,					equal_resolution=__UpperCAmelCase  )
       for image in image_inputs:
        self.assertIsInstance(__UpperCAmelCase ,					Image.Image  )

       # Test not batched input
       a		  =      image_processor(image_inputs[0] ,					return_tensors='''pt'''  ).pixel_values
       self.assertEqual(
           encoded_images.shape ,					(
               1,
               self.image_proc_tester.num_channels,
               self.image_proc_tester.size['''height'''],
               self.image_proc_tester.size['''width'''],
           ) ,					)

       # Test batched
       a		  =      image_processor(__UpperCAmelCase ,					return_tensors='''pt'''  ).pixel_values
       self.assertEqual(
           encoded_images.shape ,					(
               self.image_proc_tester.batch_size,
               self.image_proc_tester.num_channels,
               self.image_proc_tester.size['''height'''],
               self.image_proc_tester.size['''width'''],
           ) ,					)







      def       __lowerCAmelCase					(      self      :						str  )    ->str:




       """simple docstring"""


       a		  =      self.image_processing_class(**self.image_processor_dict  )
       # create random numpy tensors
       a		  =      prepare_image_inputs(self.image_proc_tester ,					equal_resolution=__UpperCAmelCase ,					numpify=__UpperCAmelCase  )
       for image in image_inputs:
        self.assertIsInstance(__UpperCAmelCase ,					np.ndarray  )

       # Test not batched input
       a		  =      image_processor(image_inputs[0] ,					return_tensors='''pt'''  ).pixel_values
       self.assertEqual(
           encoded_images.shape ,					(
               1,
               self.image_proc_tester.num_channels,
               self.image_proc_tester.size['''height'''],
               self.image_proc_tester.size['''width'''],
           ) ,					)

       # Test batched
       a		  =      image_processor(__UpperCAmelCase ,					return_tensors='''pt'''  ).pixel_values
       self.assertEqual(
           encoded_images.shape ,					(
               self.image_proc_tester.batch_size,
               self.image_proc_tester.num_channels,
               self.image_proc_tester.size['''height'''],
               self.image_proc_tester.size['''width'''],
           ) ,					)







      def       __lowerCAmelCase					(      self      :						Dict  )    ->Any:




       """simple docstring"""


       a		  =      self.image_processing_class(**self.image_processor_dict  )
       # create random PyTorch tensors
       a		  =      prepare_image_inputs(self.image_proc_tester ,					equal_resolution=__UpperCAmelCase ,					torchify=__UpperCAmelCase  )
       for image in image_inputs:
        self.assertIsInstance(__UpperCAmelCase ,					torch.Tensor  )

       # Test not batched input
       a		  =      image_processor(image_inputs[0] ,					return_tensors='''pt'''  ).pixel_values
       self.assertEqual(
           encoded_images.shape ,					(
               1,
               self.image_proc_tester.num_channels,
               self.image_proc_tester.size['''height'''],
               self.image_proc_tester.size['''width'''],
           ) ,					)

       # Test batched
       a		  =      image_processor(__UpperCAmelCase ,					return_tensors='''pt'''  ).pixel_values
       self.assertEqual(
           encoded_images.shape ,					(
               self.image_proc_tester.batch_size,
               self.image_proc_tester.num_channels,
               self.image_proc_tester.size['''height'''],
               self.image_proc_tester.size['''width'''],
           ) ,					)







"""simple docstring"""







def      __UpperCAmelCase      (    __lowerCamelCase = 50	)							->      int:
		lowercase__   :    int				=			[[0] * 3 for _ in range(length + 1	)]

		for row_length in range(length + 1	):
				for tile_length in range(2						,     5	):
						for tile_start in range(row_length - tile_length + 1	):
								different_colour_ways_number[row_length][tile_length - 2] += (
								    different_colour_ways_number[row_length - tile_start - tile_length][
								        tile_length - 2
								    ]
								    + 1
								)

		return sum(different_colour_ways_number[length]	)


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