




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 EfficientNetImageProcessor

class   UpperCAmelCase    (      unittest.TestCase ):






   def __init__(						self :							List[str]    ,       UpperCamelCase_ :							Optional[Any]    ,       UpperCamelCase_ :							List[str]=13    ,       UpperCamelCase_ :							Optional[Any]=3    ,       UpperCamelCase_ :							int=18    ,       UpperCamelCase_ :							List[str]=30    ,       UpperCamelCase_ :							List[str]=4_00    ,       UpperCamelCase_ :							Union[str, Any]=True    ,       UpperCamelCase_ :							Tuple=None    ,       UpperCamelCase_ :							int=True    ,       UpperCamelCase_ :							Tuple=[0.5, 0.5, 0.5]    ,       UpperCamelCase_ :							str=[0.5, 0.5, 0.5]    ,       )->      Optional[int]:
     _lowercase:			Dict      =     size if size is not None else {'height': 18, 'width': 18}
     _lowercase:			int      =     parent
     _lowercase:			List[str]      =     batch_size
     _lowercase:			List[Any]      =     num_channels
     _lowercase:			Tuple      =     image_size
     _lowercase:			Tuple      =     min_resolution
     _lowercase:			List[str]      =     max_resolution
     _lowercase:			Optional[Any]      =     do_resize
     _lowercase:			Union[str, Any]      =     size
     _lowercase:			Dict      =     do_normalize
     _lowercase:			Dict      =     image_mean
     _lowercase:			Optional[Any]      =     image_std






   def 			_a    (						self :							str  )->      str:
     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   UpperCAmelCase    (      A ,       unittest.TestCase ):
   __SCREAMING_SNAKE_CASE		:				List[Any]      					=       EfficientNetImageProcessor if is_vision_available() else None






   def 			_a    (						self :							str  )->      int:
     _lowercase:			Union[str, Any]      =     EfficientNetImageProcessorTester(self  )






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






   def 			_a    (						self :							Tuple  )->      str:
     _lowercase:			Optional[Any]      =     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 			_a    (						self :							Any  )->      int:
     _lowercase:			Optional[int]      =     self.image_processing_class.from_dict(self.image_processor_dict  )
     self.assertEqual(image_processor.size    ,       {'height': 18, 'width': 18}  )

     _lowercase:			Any      =     self.image_processing_class.from_dict(self.image_processor_dict    ,       size=42  )
     self.assertEqual(image_processor.size    ,       {'height': 42, 'width': 42}  )






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

     # Test not batched input
     _lowercase:			Tuple      =     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['height'],
             self.image_processor_tester.size['width'],
         )    ,       )

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

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

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

     # Test not batched input
     _lowercase:			Union[str, 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['height'],
             self.image_processor_tester.size['width'],
         )    ,       )

     # Test batched
     _lowercase:			int      =     image_processing(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'],
         )    ,       )






from math import sqrt


def 		_lowerCamelCase					(       UpperCamelCase				)      ->		list[int]:





  """simple docstring"""





  _lowercase:			Dict      =     [1]
  for i in range(2       ,  int(sqrt(UpperCamelCase				)				) + 1       ,  1				):
    if number % i == 0:
      values.append(UpperCamelCase				)
      if int(number // i				) != i:
        values.append(int(number // i				)				)
  return sorted(UpperCamelCase				)


def 		_lowerCamelCase					(       UpperCamelCase				)      ->		bool:





  """simple docstring"""





  return sum(factors(UpperCamelCase				)				) > n


def 		_lowerCamelCase					(       UpperCamelCase				)      ->		bool:





  """simple docstring"""





  _lowercase:			Dict      =     factors(UpperCamelCase				)
  _lowercase:			int      =     len(UpperCamelCase				)
  _lowercase:			Optional[int]      =     [[0 for i in range(number + 1				)] for j in range(r + 1				)]
  for i in range(r + 1				):
    _lowercase:			List[Any]      =     True

  for i in range(1       ,  number + 1				):
    _lowercase:			Optional[int]      =     False

  for i in range(1       ,  r + 1				):
    for j in range(1       ,  number + 1				):
      if j < values[i - 1]:
        _lowercase:			Optional[int]      =     subset[i - 1][j]
      else:
        _lowercase:			Optional[Any]      =     subset[i - 1][j] or subset[i - 1][j - values[i - 1]]

  return subset[r][number] != 0


def 		_lowerCamelCase					(       UpperCamelCase				)      ->		bool:





  """simple docstring"""





  return abundant(UpperCamelCase				) and not semi_perfect(UpperCamelCase				)


if __name__ == "__main__":
   import doctest

   doctest.testmod(verbose=True)
   for number in (69, 70, 71):
      print(f'''{number} is {'' if weird(number) else 'not '}weird.''')
