





'''simple docstring'''




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


     def __init__(						self						,     _UpperCAmelCase						,     _UpperCAmelCase=13						,     _UpperCAmelCase=3						,     _UpperCAmelCase=224						,     _UpperCAmelCase=30						,     _UpperCAmelCase=400						,     _UpperCAmelCase=True						,     _UpperCAmelCase=None						,     _UpperCAmelCase=True						,     _UpperCAmelCase=[0.5, 0.5, 0.5]						,     _UpperCAmelCase=[0.5, 0.5, 0.5]						,     ):

          '''simple docstring'''






          __A						:			str								=	size if size is not None else {'height': 18, 'width': 18}
          __A						:			List[Any]								=	parent
          __A						:			Optional[int]								=	batch_size
          __A						:			List[str]								=	num_channels
          __A						:			str								=	image_size
          __A						:			Union[str, Any]								=	min_resolution
          __A						:			Optional[Any]								=	max_resolution
          __A						:			Optional[Any]								=	do_resize
          __A						:			Dict								=	size
          __A						:			Tuple								=	do_normalize
          __A						:			Tuple								=	image_mean
          __A						:			str								=	image_std


     def 							SCREAMING_SNAKE_CASE  (						self):

          '''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 			SCREAMING_SNAKE_CASE   (a__ ,		unittest.TestCase							):
     lowerCAmelCase		      =	ViTImageProcessor if is_vision_available() else None


     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          __A						:			Tuple								=	EfficientFormerImageProcessorTester(self)


     @property
     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          return self.image_proc_tester.prepare_image_processor_dict()


     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          __A						:			List[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 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          pass


     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          __A						:			Optional[int]								=	self.image_processing_class(**self.image_processor_dict)
          # create random PIL images
          __A						:			Union[str, Any]								=	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						:			Tuple								=	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						:			str								=	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 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          __A						:			List[Any]								=	self.image_processing_class(**self.image_processor_dict)
          # create random numpy tensors
          __A						:			Union[str, Any]								=	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						:			List[str]								=	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						:			Union[str, Any]								=	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 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          __A						:			List[Any]								=	self.image_processing_class(**self.image_processor_dict)
          # create random PyTorch tensors
          __A						:			Optional[Any]								=	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						:			str								=	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						:			List[Any]								=	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'''




import math






def 	_lowerCAmelCase      (  __snake_case  :			int      )					->					int:

     if not isinstance(__snake_case			,							__snake_case      ):
          __A						:			List[Any]								=	f'Input value of [number={number}] must be an integer'
          raise TypeError(__snake_case      )

     if number < 1:
          __A						:			Union[str, Any]								=	f'Input value of [number={number}] must be > 0'
          raise ValueError(__snake_case      )
     elif number == 1:
          return 3
     elif number == 2:
          return 5
     else:
          __A						:			Optional[Any]								=	int(math.log(number // 3			,							2      )      ) + 2

          __A						:			Union[str, Any]								=	[3, 5]
          __A						:			List[Any]								=	2
          __A						:			Optional[Any]								=	3
          for block in range(1			,							__snake_case      ):
               for _ in range(__snake_case      ):
                    proth_list.append(2 ** (block + 1) + proth_list[proth_index - 1]      )
                    proth_index += 1
               increment *= 2

     return proth_list[number - 1]


if __name__ == "__main__":
  import doctest

  doctest.testmod()

  for number in range(11):
    lowercase__   :				str      =   0
    try:
      lowercase__   :				List[str]      =   proth(number)
    except ValueError:
      print(f"""ValueError: there is no {number}th Proth number""")
      continue

    print(f"""The {number}th Proth number: {value}""")