






"""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 CLIPImageProcessor






class __a   (   unittest.TestCase				):



  def __init__(self  :		Any				,			lowercase_  :		Dict				,			lowercase_  :		Optional[int]=7				,			lowercase_  :		str=3				,			lowercase_  :		List[str]=18				,			lowercase_  :		Union[str, Any]=30				,			lowercase_  :		Optional[Any]=400				,			lowercase_  :		Optional[int]=True				,			lowercase_  :		Tuple=None				,			lowercase_  :		str=True				,			lowercase_  :		int=None				,			lowercase_  :		Optional[Any]=True				,			lowercase_  :		Dict=[0.4814_5466, 0.457_8275, 0.4082_1073]				,			lowercase_  :		Union[str, Any]=[0.2686_2954, 0.2613_0258, 0.2757_7711]				,			lowercase_  :		Tuple=True				,			)		->							List[str]:
   __A	:       Optional[int]       =	size if size is not None else {'shortest_edge': 20}
   __A	:       Tuple       =	crop_size if crop_size is not None else {'height': 18, 'width': 18}
   __A	:       Optional[Any]       =	parent
   __A	:       Union[str, Any]       =	batch_size
   __A	:       Dict       =	num_channels
   __A	:       Optional[Any]       =	image_size
   __A	:       str       =	min_resolution
   __A	:       Optional[int]       =	max_resolution
   __A	:       Dict       =	do_resize
   __A	:       Union[str, Any]       =	size
   __A	:       Tuple       =	do_center_crop
   __A	:       Tuple       =	crop_size
   __A	:       int       =	do_normalize
   __A	:       Optional[Any]       =	image_mean
   __A	:       Dict       =	image_std
   __A	:       int       =	do_convert_rgb



  def 						A_				(self  :		Optional[int]   )		->							str:
   return {
       "do_resize": self.do_resize,
       "size": self.size,
       "do_center_crop": self.do_center_crop,
       "crop_size": self.crop_size,
       "do_normalize": self.do_normalize,
       "image_mean": self.image_mean,
       "image_std": self.image_std,
       "do_convert_rgb": self.do_convert_rgb,
   }



  def 						A_				(self  :		str				,			lowercase_  :		str=False				,			lowercase_  :		str=False				,			lowercase_  :		Union[str, Any]=False   )		->							int:
   assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

   if equal_resolution:
    __A	:       Optional[int]       =	[]
    for i in range(self.batch_size   ):
     image_inputs.append(
         np.random.randint(
             255				,			size=(self.num_channels, self.max_resolution, self.max_resolution)				,			dtype=np.uinta   )   )
   else:
    __A	:       Tuple       =	[]
    for i in range(self.batch_size   ):
     __A    ,					__A	:       Any       =	np.random.choice(np.arange(self.min_resolution				,			self.max_resolution   )				,			2   )
     image_inputs.append(np.random.randint(255				,			size=(self.num_channels, width, height)				,			dtype=np.uinta   )   )

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

   if torchify:
    __A	:       Union[str, Any]       =	[torch.from_numpy(lowercase_   ) for x in image_inputs]

   return image_inputs






@require_torch
@require_vision
class __a   (   snake_case_ ,unittest.TestCase				):
  __lowercase    :    Any						=					CLIPImageProcessor if is_vision_available() else None



  def 						A_				(self  :		Any   )		->							Optional[Any]:
   __A	:       Tuple       =	CLIPImageProcessingTester(self   )



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



  def 						A_				(self  :		int   )		->							Tuple:
   __A	:       Optional[Any]       =	self.image_processing_class(**self.image_processor_dict   )
   self.assertTrue(hasattr(lowercase_				,			'do_resize'   )   )
   self.assertTrue(hasattr(lowercase_				,			'size'   )   )
   self.assertTrue(hasattr(lowercase_				,			'do_center_crop'   )   )
   self.assertTrue(hasattr(lowercase_				,			'center_crop'   )   )
   self.assertTrue(hasattr(lowercase_				,			'do_normalize'   )   )
   self.assertTrue(hasattr(lowercase_				,			'image_mean'   )   )
   self.assertTrue(hasattr(lowercase_				,			'image_std'   )   )
   self.assertTrue(hasattr(lowercase_				,			'do_convert_rgb'   )   )



  def 						A_				(self  :		Optional[Any]   )		->							Dict:
   __A	:       str       =	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}   )

   __A	:       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 						A_				(self  :		Any   )		->							int:
   pass



  def 						A_				(self  :		Any   )		->							Tuple:
   # Initialize image_processing
   __A	:       Optional[Any]       =	self.image_processing_class(**self.image_processor_dict   )
   # create random PIL images
   __A	:       List[Any]       =	self.image_processor_tester.prepare_inputs(equal_resolution=lowercase_   )
   for image in image_inputs:
    self.assertIsInstance(lowercase_				,			Image.Image   )

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

   # Test not batched input
   __A	:       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
   __A	:       Tuple       =	image_processing(lowercase_				,			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 						A_				(self  :		List[str]   )		->							Optional[Any]:
   # Initialize image_processing
   __A	:       Dict       =	self.image_processing_class(**self.image_processor_dict   )
   # create random PyTorch tensors
   __A	:       List[Any]       =	self.image_processor_tester.prepare_inputs(equal_resolution=lowercase_				,			torchify=lowercase_   )
   for image in image_inputs:
    self.assertIsInstance(lowercase_				,			torch.Tensor   )

   # Test not batched input
   __A	:       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
   __A	:       str       =	image_processing(lowercase_				,			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'],
       )				,			)






@require_torch
@require_vision
class __a   (   snake_case_ ,unittest.TestCase				):
  __lowercase    :    List[str]						=					CLIPImageProcessor if is_vision_available() else None



  def 						A_				(self  :		int   )		->							List[str]:
   __A	:       Any       =	CLIPImageProcessingTester(self				,			num_channels=4   )
   __A	:       Union[str, Any]       =	3



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



  def 						A_				(self  :		List[str]   )		->							Union[str, Any]:
   __A	:       Tuple       =	self.image_processing_class(**self.image_processor_dict   )
   self.assertTrue(hasattr(lowercase_				,			'do_resize'   )   )
   self.assertTrue(hasattr(lowercase_				,			'size'   )   )
   self.assertTrue(hasattr(lowercase_				,			'do_center_crop'   )   )
   self.assertTrue(hasattr(lowercase_				,			'center_crop'   )   )
   self.assertTrue(hasattr(lowercase_				,			'do_normalize'   )   )
   self.assertTrue(hasattr(lowercase_				,			'image_mean'   )   )
   self.assertTrue(hasattr(lowercase_				,			'image_std'   )   )
   self.assertTrue(hasattr(lowercase_				,			'do_convert_rgb'   )   )



  def 						A_				(self  :		Any   )		->							List[Any]:
   pass



  def 						A_				(self  :		List[str]   )		->							List[str]:
   # Initialize image_processing
   __A	:       Union[str, Any]       =	self.image_processing_class(**self.image_processor_dict   )
   # create random PIL images
   __A	:       Tuple       =	self.image_processor_tester.prepare_inputs(equal_resolution=lowercase_   )
   for image in image_inputs:
    self.assertIsInstance(lowercase_				,			Image.Image   )

   # Test not batched input
   __A	:       int       =	image_processing(image_inputs[0]				,			return_tensors='pt'   ).pixel_values
   self.assertEqual(
       encoded_images.shape				,			(
           1,
           self.expected_encoded_image_num_channels,
           self.image_processor_tester.crop_size['height'],
           self.image_processor_tester.crop_size['width'],
       )				,			)

   # Test batched
   __A	:       Union[str, Any]       =	image_processing(lowercase_				,			return_tensors='pt'   ).pixel_values
   self.assertEqual(
       encoded_images.shape				,			(
           self.image_processor_tester.batch_size,
           self.expected_encoded_image_num_channels,
           self.image_processor_tester.crop_size['height'],
           self.image_processor_tester.crop_size['width'],
       )				,			)













"""simple docstring"""


import math




def 				a (     UpperCamelCase_							:				int		)  ->		list[int]:
 if not isinstance(UpperCamelCase_     ,	UpperCamelCase_		):
  __A	:       Any       =	F"Input value of [number={number}] must be an integer"
  raise TypeError(UpperCamelCase_		)
 if number < 1:
  __A	:       int       =	F"Input value of [number={number}] must be a positive integer"
  raise ValueError(UpperCamelCase_		)
 __A	:       Optional[Any]       =	[number]
 while number != 1:
  if number % 2 == 0:
   __A	:       Optional[int]       =	math.floor(math.sqrt(UpperCamelCase_		)		)
  else:
   __A	:       List[str]       =	math.floor(
       math.sqrt(UpperCamelCase_		) * math.sqrt(UpperCamelCase_		) * math.sqrt(UpperCamelCase_		)		)
  sequence.append(UpperCamelCase_		)
 return sequence


if __name__ == "__main__":
   import doctest

   doctest.testmod()





