


import math






def 		a__       (							A__							):


			if not isinstance(SCREAMING_SNAKE_CASE__,	SCREAMING_SNAKE_CASE__							):
						SCREAMING_SNAKE_CASE_						:			Any       						= F'''Input value of [number={number}] must be an integer'''
						raise TypeError(SCREAMING_SNAKE_CASE__							)
			if number < 1:
						SCREAMING_SNAKE_CASE_						:			List[str]       						= F'''Input value of [number={number}] must be a positive integer'''
						raise ValueError(SCREAMING_SNAKE_CASE__							)
			SCREAMING_SNAKE_CASE_						:			List[Any]       						= [number]
			while number != 1:
						if number % 2 == 0:
									SCREAMING_SNAKE_CASE_						:			Tuple       						= math.floor(math.sqrt(SCREAMING_SNAKE_CASE__							)							)
						else:
									SCREAMING_SNAKE_CASE_						:			List[Any]       						= math.floor(
									    math.sqrt(SCREAMING_SNAKE_CASE__							) * math.sqrt(SCREAMING_SNAKE_CASE__							) * math.sqrt(SCREAMING_SNAKE_CASE__							)							)
						sequence.append(SCREAMING_SNAKE_CASE__							)
			return sequence


if __name__ == "__main__":
				import doctest

				doctest.testmod()







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






class      snake_case__    (	unittest.TestCase ):







		"""simple docstring"""

		def __init__(	self							:       List[str]   ,     UpperCamelCase__							:       Union[str, Any]   ,     UpperCamelCase__							:       Optional[Any]=7   ,     UpperCamelCase__							:       Union[str, Any]=3   ,     UpperCamelCase__							:       Tuple=18   ,     UpperCamelCase__							:       Union[str, Any]=30   ,     UpperCamelCase__							:       Dict=400   ,     UpperCamelCase__							:       Tuple=True   ,     UpperCamelCase__							:       Optional[Any]=None   ,     UpperCamelCase__							:       Any=True   ,     UpperCamelCase__							:       Dict=False   ,     UpperCamelCase__							:       Dict=[0.48_145_466, 0.4_578_275, 0.40_821_073]   ,     UpperCamelCase__							:       int=[0.26_862_954, 0.26_130_258, 0.27_577_711]   ,     UpperCamelCase__							:       str=True   ,     )		->       Any:






				"""simple docstring"""







				snake_case   :    Dict			       =		size if size is not None else {'''height''': 20, '''width''': 20}
				snake_case   :    Union[str, Any]			       =		parent
				snake_case   :    Optional[int]			       =		batch_size
				snake_case   :    Dict			       =		num_channels
				snake_case   :    List[Any]			       =		image_size
				snake_case   :    List[Any]			       =		min_resolution
				snake_case   :    Dict			       =		max_resolution
				snake_case   :    Dict			       =		do_resize
				snake_case   :    Optional[int]			       =		size
				snake_case   :    Dict			       =		do_normalize
				snake_case   :    Tuple			       =		image_mean
				snake_case   :    Optional[int]			       =		image_std
				snake_case   :    int			       =		do_pad
				snake_case   :    List[Any]			       =		do_convert_rgb



		def 	lowerCAmelCase							(	self							:       str	)		->       Optional[int]:






				"""simple docstring"""







				return {
				    "do_resize": self.do_resize,
				    "size": self.size,
				    "do_normalize": self.do_normalize,
				    "image_mean": self.image_mean,
				    "image_std": self.image_std,
				    "do_convert_rgb": self.do_convert_rgb,
				    "do_pad": self.do_pad,
				}



		def 	lowerCAmelCase							(	self							:       str   ,     UpperCamelCase__							:       Optional[int]=False   ,     UpperCamelCase__							:       Tuple=False   ,     UpperCamelCase__							:       Union[str, Any]=False	)		->       List[str]:






				"""simple docstring"""







				assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

				if equal_resolution:
						snake_case   :    Any			       =		[]
						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:
						snake_case   :    Union[str, Any]			       =		[]
						for i in range(self.batch_size	):
								snake_case       ,snake_case   :    List[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
						snake_case   :    Optional[int]			       =		[Image.fromarray(np.moveaxis(UpperCamelCase__   ,     0   ,     -1	)	) for x in image_inputs]

				if torchify:
						snake_case   :    Optional[Any]			       =		[torch.from_numpy(UpperCamelCase__	) for x in image_inputs]

				return image_inputs







@require_torch
@require_vision
class      snake_case__    (	__SCREAMING_SNAKE_CASE  , unittest.TestCase ):







		"""simple docstring"""

		lowerCamelCase							=		BlipImageProcessor if is_vision_available() else None



		def 	lowerCAmelCase							(	self							:       Dict	)		->       Optional[int]:






				"""simple docstring"""







				snake_case   :    Union[str, Any]			       =		BlipImageProcessingTester(self	)



		@property
		def 	lowerCAmelCase							(	self							:       Any	)		->       Union[str, Any]:






				"""simple docstring"""







				return self.image_processor_tester.prepare_image_processor_dict()



		def 	lowerCAmelCase							(	self							:       Optional[Any]	)		->       Any:






				"""simple docstring"""







				snake_case   :    Dict			       =		self.image_processing_class(**self.image_processor_dict	)
				self.assertTrue(hasattr(UpperCamelCase__   ,     '''do_resize'''	)	)
				self.assertTrue(hasattr(UpperCamelCase__   ,     '''size'''	)	)
				self.assertTrue(hasattr(UpperCamelCase__   ,     '''do_normalize'''	)	)
				self.assertTrue(hasattr(UpperCamelCase__   ,     '''image_mean'''	)	)
				self.assertTrue(hasattr(UpperCamelCase__   ,     '''image_std'''	)	)
				self.assertTrue(hasattr(UpperCamelCase__   ,     '''do_convert_rgb'''	)	)



		def 	lowerCAmelCase							(	self							:       Any	)		->       Dict:






				"""simple docstring"""







				pass



		def 	lowerCAmelCase							(	self							:       List[str]	)		->       Tuple:






				"""simple docstring"""







				snake_case   :    Optional[Any]			       =		self.image_processing_class(**self.image_processor_dict	)
				# create random PIL images
				snake_case   :    Union[str, Any]			       =		self.image_processor_tester.prepare_inputs(equal_resolution=UpperCamelCase__	)
				for image in image_inputs:
						self.assertIsInstance(UpperCamelCase__   ,     Image.Image	)

				# Test not batched input
				snake_case   :    Optional[int]			       =		image_processor(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
				snake_case   :    int			       =		image_processor(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 	lowerCAmelCase							(	self							:       List[str]	)		->       Tuple:






				"""simple docstring"""







				snake_case   :    Any			       =		self.image_processing_class(**self.image_processor_dict	)
				# create random numpy tensors
				snake_case   :    List[str]			       =		self.image_processor_tester.prepare_inputs(equal_resolution=UpperCamelCase__   ,     numpify=UpperCamelCase__	)
				for image in image_inputs:
						self.assertIsInstance(UpperCamelCase__   ,     np.ndarray	)

				# Test not batched input
				snake_case   :    Dict			       =		image_processor(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
				snake_case   :    Dict			       =		image_processor(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 	lowerCAmelCase							(	self							:       Dict	)		->       Union[str, Any]:






				"""simple docstring"""







				snake_case   :    Union[str, Any]			       =		self.image_processing_class(**self.image_processor_dict	)
				# create random PyTorch tensors
				snake_case   :    List[Any]			       =		self.image_processor_tester.prepare_inputs(equal_resolution=UpperCamelCase__   ,     torchify=UpperCamelCase__	)
				for image in image_inputs:
						self.assertIsInstance(UpperCamelCase__   ,     torch.Tensor	)

				# Test not batched input
				snake_case   :    List[str]			       =		image_processor(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
				snake_case   :    str			       =		image_processor(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'''],
				    )   ,     )







@require_torch
@require_vision
class      snake_case__    (	__SCREAMING_SNAKE_CASE  , unittest.TestCase ):







		"""simple docstring"""

		lowerCamelCase							=		BlipImageProcessor if is_vision_available() else None



		def 	lowerCAmelCase							(	self							:       Tuple	)		->       Union[str, Any]:






				"""simple docstring"""







				snake_case   :    Union[str, Any]			       =		BlipImageProcessingTester(self   ,     num_channels=4	)
				snake_case   :    Optional[int]			       =		3



		@property
		def 	lowerCAmelCase							(	self							:       Optional[int]	)		->       Tuple:






				"""simple docstring"""







				return self.image_processor_tester.prepare_image_processor_dict()



		def 	lowerCAmelCase							(	self							:       List[Any]	)		->       Any:






				"""simple docstring"""







				snake_case   :    Union[str, 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_normalize'''	)	)
				self.assertTrue(hasattr(UpperCamelCase__   ,     '''image_mean'''	)	)
				self.assertTrue(hasattr(UpperCamelCase__   ,     '''image_std'''	)	)
				self.assertTrue(hasattr(UpperCamelCase__   ,     '''do_convert_rgb'''	)	)



		def 	lowerCAmelCase							(	self							:       Optional[Any]	)		->       List[str]:






				"""simple docstring"""







				pass



		def 	lowerCAmelCase							(	self							:       Optional[int]	)		->       Any:






				"""simple docstring"""







				snake_case   :    Optional[Any]			       =		self.image_processing_class(**self.image_processor_dict	)
				# create random PIL images
				snake_case   :    Tuple			       =		self.image_processor_tester.prepare_inputs(equal_resolution=UpperCamelCase__	)
				for image in image_inputs:
						self.assertIsInstance(UpperCamelCase__   ,     Image.Image	)

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

				# Test batched
				snake_case   :    Union[str, Any]			       =		image_processor(UpperCamelCase__   ,     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.size['''height'''],
				        self.image_processor_tester.size['''width'''],
				    )   ,     )


