




'''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


if is_torch_available():
       import torch

if is_vision_available():
       from PIL import Image

       from transformers import SwinaSRImageProcessor
       from transformers.image_transforms import get_image_size






class 						lowercase     (   unittest.TestCase):






      def __init__(self ,  a__ ,  a__=7 ,  a__=3 ,  a__=1_8 ,  a__=3_0 ,  a__=4_0_0 ,  a__=True ,  a__=1 / 2_5_5 ,  a__=True ,  a__=8 ,  )       ->   Optional[Any]:
         SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= parent
         SCREAMING_SNAKE_CASE__			:				Any       						= batch_size
         SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= num_channels
         SCREAMING_SNAKE_CASE__			:				int       						= image_size
         SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= min_resolution
         SCREAMING_SNAKE_CASE__			:				Any       						= max_resolution
         SCREAMING_SNAKE_CASE__			:				Optional[Any]       						= do_rescale
         SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= rescale_factor
         SCREAMING_SNAKE_CASE__			:				Tuple       						= do_pad
         SCREAMING_SNAKE_CASE__			:				List[str]       						= pad_size






      def    A__(self					)       ->   Tuple:
         return {
             "do_rescale": self.do_rescale,
             "rescale_factor": self.rescale_factor,
             "do_pad": self.do_pad,
             "pad_size": self.pad_size,
         }






      def    A__(self ,  a__=False ,  a__=False ,  a__=False					)       ->   Tuple:
         assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

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

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

         if torchify:
            SCREAMING_SNAKE_CASE__			:				List[Any]       						= [torch.from_numpy(a__					) for x in image_inputs]

         return image_inputs






@require_torch
@require_vision
class 						lowercase     (   UpperCAmelCase_				,			unittest.TestCase):
      __lowercase 		=  SwinaSRImageProcessor if is_vision_available() else None






      def    A__(self					)       ->   Union[str, Any]:
         SCREAMING_SNAKE_CASE__			:				str       						= SwinaSRImageProcessingTester(self					)






      @property
      def    A__(self					)       ->   List[str]:
         return self.image_processor_tester.prepare_image_processor_dict()






      def    A__(self					)       ->   Optional[Any]:
         SCREAMING_SNAKE_CASE__			:				Optional[int]       						= self.image_processing_class(**self.image_processor_dict					)
         self.assertTrue(hasattr(a__ ,  '''do_rescale'''					)					)
         self.assertTrue(hasattr(a__ ,  '''rescale_factor'''					)					)
         self.assertTrue(hasattr(a__ ,  '''do_pad'''					)					)
         self.assertTrue(hasattr(a__ ,  '''pad_size'''					)					)






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






      def    A__(self ,  a__					)       ->   List[str]:
         SCREAMING_SNAKE_CASE__						,				SCREAMING_SNAKE_CASE__			:				str       						= get_image_size(a__					)
         SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= self.image_processor_tester.pad_size

         SCREAMING_SNAKE_CASE__			:				str       						= (old_height // size + 1) * size - old_height
         SCREAMING_SNAKE_CASE__			:				int       						= (old_width // size + 1) * size - old_width
         return old_height + pad_height, old_width + pad_width






      def    A__(self					)       ->   List[str]:
         # Initialize image_processor
         SCREAMING_SNAKE_CASE__			:				List[Any]       						= self.image_processing_class(**self.image_processor_dict					)
         # create random PIL images
         SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= self.image_processor_tester.prepare_inputs(equal_resolution=a__					)
         for image in image_inputs:
            self.assertIsInstance(a__ ,  Image.Image					)

         # Test not batched input
         SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= image_processor(image_inputs[0] ,  return_tensors='''pt'''					).pixel_values
         SCREAMING_SNAKE_CASE__						,				SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= self.calculate_expected_size(np.array(image_inputs[0]					)					)
         self.assertEqual(
             encoded_images.shape ,  (
                 1,
                 self.image_processor_tester.num_channels,
                 expected_height,
                 expected_width,
             ) ,  )






      def    A__(self					)       ->   List[Any]:
         # Initialize image_processor
         SCREAMING_SNAKE_CASE__			:				str       						= self.image_processing_class(**self.image_processor_dict					)
         # create random numpy tensors
         SCREAMING_SNAKE_CASE__			:				Any       						= self.image_processor_tester.prepare_inputs(equal_resolution=a__ ,  numpify=a__					)
         for image in image_inputs:
            self.assertIsInstance(a__ ,  np.ndarray					)

         # Test not batched input
         SCREAMING_SNAKE_CASE__			:				Tuple       						= image_processor(image_inputs[0] ,  return_tensors='''pt'''					).pixel_values
         SCREAMING_SNAKE_CASE__						,				SCREAMING_SNAKE_CASE__			:				Any       						= self.calculate_expected_size(image_inputs[0]					)
         self.assertEqual(
             encoded_images.shape ,  (
                 1,
                 self.image_processor_tester.num_channels,
                 expected_height,
                 expected_width,
             ) ,  )






      def    A__(self					)       ->   Dict:
         # Initialize image_processor
         SCREAMING_SNAKE_CASE__			:				List[Any]       						= self.image_processing_class(**self.image_processor_dict					)
         # create random PyTorch tensors
         SCREAMING_SNAKE_CASE__			:				str       						= self.image_processor_tester.prepare_inputs(equal_resolution=a__ ,  torchify=a__					)
         for image in image_inputs:
            self.assertIsInstance(a__ ,  torch.Tensor					)

         # Test not batched input
         SCREAMING_SNAKE_CASE__			:				List[str]       						= image_processor(image_inputs[0] ,  return_tensors='''pt'''					).pixel_values
         SCREAMING_SNAKE_CASE__						,				SCREAMING_SNAKE_CASE__			:				Union[str, Any]       						= self.calculate_expected_size(image_inputs[0]					)
         self.assertEqual(
             encoded_images.shape ,  (
                 1,
                 self.image_processor_tester.num_channels,
                 expected_height,
                 expected_width,
             ) ,  )







'''simple docstring'''





def 				UpperCamelCase	(  snake_case = 99_80_01   ):




   '''simple docstring'''

   for number in range(n - 1	,     99_99	,     -1   ):
      SCREAMING_SNAKE_CASE__			:				int       						= str(snake_case   )

      # checks whether 'str_number' is a palindrome.
      if str_number == str_number[::-1]:
         SCREAMING_SNAKE_CASE__			:				Any       						= 9_99

         # if 'number' is a product of two 3-digit numbers
         # then number is the answer otherwise fetch next number.
         while divisor != 99:
            if (number % divisor == 0) and (len(str(number // divisor   )   ) == 3.0):
               return number
            divisor -= 1
   raise ValueError('''That number is larger than our acceptable range.'''   )


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

