

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

   '''simple docstring'''




   def __init__(							self,       lowercase_,       lowercase_=13,       lowercase_=3,       lowercase_=18,       lowercase_=30,       lowercase_=400,       lowercase_=True,       lowercase_=None,       lowercase_=True,       lowercase_=[0.5, 0.5, 0.5],       lowercase_=[0.5, 0.5, 0.5],       )				->       str:






     """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 					_UpperCAmelCase					(							self			)				->       Tuple:






     """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 		__magic_name__     (				a__						,			unittest.TestCase				):

   '''simple docstring'''




   lowerCamelCase__					:      Dict        =  EfficientNetImageProcessor if is_vision_available() else None



   def 					_UpperCAmelCase					(							self			)				->       Any:






     """simple docstring"""






     a__    =EfficientNetImageProcessorTester(self			)



   @property
   def 					_UpperCAmelCase					(							self			)				->       Dict:






     """simple docstring"""






     return self.image_processor_tester.prepare_image_processor_dict()



   def 					_UpperCAmelCase					(							self			)				->       Optional[int]:






     """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 					_UpperCAmelCase					(							self			)				->       Optional[Any]:






     """simple docstring"""






     a__    =self.image_processing_class.from_dict(self.image_processor_dict			)
     self.assertEqual(image_processor.size,       {'''height''': 18, '''width''': 18}			)

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



   def 					_UpperCAmelCase					(							self			)				->       List[str]:






     """simple docstring"""






     a__    =self.image_processing_class(**self.image_processor_dict			)
     # create random PIL images
     a__    =prepare_image_inputs(self.image_processor_tester,       equal_resolution=UpperCamelCase_			)
     for image in image_inputs:
       self.assertIsInstance(UpperCamelCase_,       Image.Image			)

     # Test not batched input
     a__    =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
     a__    =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 					_UpperCAmelCase					(							self			)				->       Any:






     """simple docstring"""






     a__    =self.image_processing_class(**self.image_processor_dict			)
     # create random numpy tensors
     a__    =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
     a__    =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
     a__    =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 					_UpperCAmelCase					(							self			)				->       int:






     """simple docstring"""






     a__    =self.image_processing_class(**self.image_processor_dict			)
     # create random PyTorch tensors
     a__    =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
     a__    =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
     a__    =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'''],
         ),       )




"""simple docstring"""





from doctest import testmod
from math import sqrt


def   _snake_case    (    _snake_case					:      int      ):
      lowerCAmelCase       :						list[int]							= []
      if num < 1:
            return facs
      facs.append(1      )
      if num == 1:
            return facs
      facs.append(_snake_case      )
      for i in range(2			, int(sqrt(_snake_case      )      ) + 1      ):
            if num % i == 0:  # If i is a factor of num
                  facs.append(_snake_case      )
                  lowerCAmelCase       :						Dict							= num // i  # num//i is the other factor of num
                  if d != i:  # If d and i are distinct
                        facs.append(_snake_case      )  # we have found another factor
      facs.sort()
      return facs


if __name__ == "__main__":
 testmod(name='''factors_of_a_number''', verbose=True)


