



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




class 				__lowerCAmelCase(							unittest.TestCase      ):






			def __init__(   self  :							int      ,       SCREAMING_SNAKE_CASE  :							Optional[int]      ,       SCREAMING_SNAKE_CASE  :							Optional[Any]=7      ,       SCREAMING_SNAKE_CASE  :							List[str]=3      ,       SCREAMING_SNAKE_CASE  :							Dict=18      ,       SCREAMING_SNAKE_CASE  :							str=30      ,       SCREAMING_SNAKE_CASE  :							str=400      ,       SCREAMING_SNAKE_CASE  :							int=True      ,       SCREAMING_SNAKE_CASE  :							int=None      ,       SCREAMING_SNAKE_CASE  :							List[str]=True      ,       SCREAMING_SNAKE_CASE  :							Tuple=None      ,       ):




					"""simple docstring"""







					SCREAMING_SNAKE_CASE_						:Union[str, Any]										=      size if size is not None else {'''shortest_edge''': 20}
					SCREAMING_SNAKE_CASE_						:Tuple										=      crop_size if crop_size is not None else {'''height''': 18, '''width''': 18}
					SCREAMING_SNAKE_CASE_						:List[str]										=      parent
					SCREAMING_SNAKE_CASE_						:Any										=      batch_size
					SCREAMING_SNAKE_CASE_						:List[Any]										=      num_channels
					SCREAMING_SNAKE_CASE_						:Optional[int]										=      image_size
					SCREAMING_SNAKE_CASE_						:str										=      min_resolution
					SCREAMING_SNAKE_CASE_						:Tuple										=      max_resolution
					SCREAMING_SNAKE_CASE_						:List[Any]										=      do_resize
					SCREAMING_SNAKE_CASE_						:str										=      size
					SCREAMING_SNAKE_CASE_						:Optional[Any]										=      do_center_crop
					SCREAMING_SNAKE_CASE_						:str										=      crop_size






			def 				_lowercase	(   self  :							Union[str, Any]	):




					"""simple docstring"""







					return {
					    "do_resize": self.do_resize,
					    "size": self.size,
					    "do_center_crop": self.do_center_crop,
					    "crop_size": self.crop_size,
					}




@require_torch
@require_vision
class 				__lowerCAmelCase(							a__		,			unittest.TestCase      ):
			__snake_case  :		List[Any]		=      MobileNetVaImageProcessor if is_vision_available() else None






			def 				_lowercase	(   self  :							Union[str, Any]	):




					"""simple docstring"""







					SCREAMING_SNAKE_CASE_						:List[str]										=      MobileNetVaImageProcessingTester(self	)






			@property
			def 				_lowercase	(   self  :							Optional[int]	):




					"""simple docstring"""







					return self.image_processor_tester.prepare_image_processor_dict()






			def 				_lowercase	(   self  :							Optional[int]	):




					"""simple docstring"""







					SCREAMING_SNAKE_CASE_						:List[Any]										=      self.image_processing_class(**self.image_processor_dict	)
					self.assertTrue(hasattr(UpperCamelCase_      ,       'do_resize'	)	)
					self.assertTrue(hasattr(UpperCamelCase_      ,       'size'	)	)
					self.assertTrue(hasattr(UpperCamelCase_      ,       'do_center_crop'	)	)
					self.assertTrue(hasattr(UpperCamelCase_      ,       'center_crop'	)	)






			def 				_lowercase	(   self  :							Union[str, Any]	):




					"""simple docstring"""







					SCREAMING_SNAKE_CASE_						:Dict										=      self.image_processing_class.from_dict(self.image_processor_dict	)
					self.assertEqual(image_processor.size      ,       {'shortest_edge': 20}	)
					self.assertEqual(image_processor.crop_size      ,       {'height': 18, 'width': 18}	)

					SCREAMING_SNAKE_CASE_						:str										=      self.image_processing_class.from_dict(self.image_processor_dict      ,       size=42      ,       crop_size=84	)
					self.assertEqual(image_processor.size      ,       {'shortest_edge': 42}	)
					self.assertEqual(image_processor.crop_size      ,       {'height': 84, 'width': 84}	)






			def 				_lowercase	(   self  :							Tuple	):




					"""simple docstring"""







					pass






			def 				_lowercase	(   self  :							Union[str, Any]	):




					"""simple docstring"""







					SCREAMING_SNAKE_CASE_						:List[Any]										=      self.image_processing_class(**self.image_processor_dict	)
					# create random PIL images
					SCREAMING_SNAKE_CASE_						:Union[str, 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
					SCREAMING_SNAKE_CASE_						:Optional[int]										=      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.crop_size['height'],
					        self.image_processor_tester.crop_size['width'],
					    )      ,       )

					# Test batched
					SCREAMING_SNAKE_CASE_						:List[str]										=      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.crop_size['height'],
					        self.image_processor_tester.crop_size['width'],
					    )      ,       )






			def 				_lowercase	(   self  :							List[str]	):




					"""simple docstring"""







					SCREAMING_SNAKE_CASE_						:int										=      self.image_processing_class(**self.image_processor_dict	)
					# create random numpy tensors
					SCREAMING_SNAKE_CASE_						:Optional[Any]										=      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
					SCREAMING_SNAKE_CASE_						: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.crop_size['height'],
					        self.image_processor_tester.crop_size['width'],
					    )      ,       )

					# Test batched
					SCREAMING_SNAKE_CASE_						:str										=      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.crop_size['height'],
					        self.image_processor_tester.crop_size['width'],
					    )      ,       )






			def 				_lowercase	(   self  :							str	):




					"""simple docstring"""







					SCREAMING_SNAKE_CASE_						:Dict										=      self.image_processing_class(**self.image_processor_dict	)
					# create random PyTorch tensors
					SCREAMING_SNAKE_CASE_						:List[Any]										=      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
					SCREAMING_SNAKE_CASE_						: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.crop_size['height'],
					        self.image_processor_tester.crop_size['width'],
					    )      ,       )

					# Test batched
					SCREAMING_SNAKE_CASE_						:Optional[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.crop_size['height'],
					        self.image_processor_tester.crop_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)


