






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 ConvNextImageProcessor







class       UpperCAmelCase_						( unittest.TestCase			):



      """simple docstring"""
      def __init__(    self   ,    SCREAMING_SNAKE_CASE_   ,    SCREAMING_SNAKE_CASE_=7   ,    SCREAMING_SNAKE_CASE_=3   ,    SCREAMING_SNAKE_CASE_=18   ,    SCREAMING_SNAKE_CASE_=30   ,    SCREAMING_SNAKE_CASE_=400   ,    SCREAMING_SNAKE_CASE_=True   ,    SCREAMING_SNAKE_CASE_=None   ,    SCREAMING_SNAKE_CASE_=0.875   ,    SCREAMING_SNAKE_CASE_=True   ,    SCREAMING_SNAKE_CASE_=[0.5, 0.5, 0.5]   ,    SCREAMING_SNAKE_CASE_=[0.5, 0.5, 0.5]   ,    )    ->				Tuple:
          UpperCamelCase	:int     							=       size if size is not None else {'''shortest_edge''': 20}
          UpperCamelCase	:Union[str, Any]     							=       parent
          UpperCamelCase	:Any     							=       batch_size
          UpperCamelCase	:Union[str, Any]     							=       num_channels
          UpperCamelCase	:Union[str, Any]     							=       image_size
          UpperCamelCase	:Optional[int]     							=       min_resolution
          UpperCamelCase	:Optional[int]     							=       max_resolution
          UpperCamelCase	:Any     							=       do_resize
          UpperCamelCase	:List[Any]     							=       size
          UpperCamelCase	:Any     							=       crop_pct
          UpperCamelCase	:int     							=       do_normalize
          UpperCamelCase	:Optional[int]     							=       image_mean
          UpperCamelCase	:str     							=       image_std




      def    UpperCAmelCase						(    self			)    ->				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,
              "crop_pct": self.crop_pct,
          }







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



      """simple docstring"""
      UpperCamelCase_    : Any									=ConvNextImageProcessor if is_vision_available() else None
      def    UpperCAmelCase						(    self			)    ->				List[str]:
          UpperCamelCase	:List[str]     							=       ConvNextImageProcessingTester(self			)
      @property
      def    UpperCAmelCase						(    self			)    ->				str:
          return self.image_processor_tester.prepare_image_processor_dict()
      def    UpperCAmelCase						(    self			)    ->				Dict:
          UpperCamelCase	:Tuple     							=       self.image_processing_class(**self.image_processor_dict			)
          self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_   ,    '''do_resize'''			)			)
          self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_   ,    '''size'''			)			)
          self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_   ,    '''crop_pct'''			)			)
          self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_   ,    '''do_normalize'''			)			)
          self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_   ,    '''image_mean'''			)			)
          self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_   ,    '''image_std'''			)			)
      def    UpperCAmelCase						(    self			)    ->				List[Any]:
          UpperCamelCase	:Optional[Any]     							=       self.image_processing_class.from_dict(self.image_processor_dict			)
          self.assertEqual(image_processor.size   ,    {'''shortest_edge''': 20}			)

          UpperCamelCase	:Tuple     							=       self.image_processing_class.from_dict(self.image_processor_dict   ,    size=42			)
          self.assertEqual(image_processor.size   ,    {'''shortest_edge''': 42}			)
      def    UpperCAmelCase						(    self			)    ->				str:
          pass
      def    UpperCAmelCase						(    self			)    ->				int:
          # Initialize image_processing
          UpperCamelCase	:int     							=       self.image_processing_class(**self.image_processor_dict			)
          # create random PIL images
          UpperCamelCase	:Tuple     							=       prepare_image_inputs(self.image_processor_tester   ,    equal_resolution=SCREAMING_SNAKE_CASE_			)
          for image in image_inputs:
              self.assertIsInstance(SCREAMING_SNAKE_CASE_   ,    Image.Image			)

          # Test not batched input
          UpperCamelCase	: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['''shortest_edge'''],
                  self.image_processor_tester.size['''shortest_edge'''],
              )   ,    )

          # Test batched
          UpperCamelCase	:Optional[Any]     							=       image_processing(SCREAMING_SNAKE_CASE_   ,    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['''shortest_edge'''],
                  self.image_processor_tester.size['''shortest_edge'''],
              )   ,    )
      def    UpperCAmelCase						(    self			)    ->				Optional[Any]:
          # Initialize image_processing
          UpperCamelCase	:Any     							=       self.image_processing_class(**self.image_processor_dict			)
          # create random numpy tensors
          UpperCamelCase	:str     							=       prepare_image_inputs(self.image_processor_tester   ,    equal_resolution=SCREAMING_SNAKE_CASE_   ,    numpify=SCREAMING_SNAKE_CASE_			)
          for image in image_inputs:
              self.assertIsInstance(SCREAMING_SNAKE_CASE_   ,    np.ndarray			)

          # Test not batched input
          UpperCamelCase	: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['''shortest_edge'''],
                  self.image_processor_tester.size['''shortest_edge'''],
              )   ,    )

          # Test batched
          UpperCamelCase	:Optional[int]     							=       image_processing(SCREAMING_SNAKE_CASE_   ,    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['''shortest_edge'''],
                  self.image_processor_tester.size['''shortest_edge'''],
              )   ,    )




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

          # Test not batched input
          UpperCamelCase	: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['''shortest_edge'''],
                  self.image_processor_tester.size['''shortest_edge'''],
              )   ,    )

          # Test batched
          UpperCamelCase	:int     							=       image_processing(SCREAMING_SNAKE_CASE_   ,    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['''shortest_edge'''],
                  self.image_processor_tester.size['''shortest_edge'''],
              )   ,    )













def   _A       (    SCREAMING_SNAKE_CASE__  :     int = 998001	):

    # fetches the next number
    for number in range(n - 1					,  9999					,  -1	):
        UpperCamelCase	:Union[str, Any]     							=       str(SCREAMING_SNAKE_CASE__	)

        # checks whether 'str_number' is a palindrome.
        if str_number == str_number[::-1]:
            UpperCamelCase	:Dict     							=       999

            # 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() = }''')





