




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 LevitImageProcessor







class        __lowerCAmelCase					(			unittest.TestCase					):

			"""simple docstring"""







			def __init__( self     ,		lowerCamelCase__     ,		lowerCamelCase__=7     ,		lowerCamelCase__=3     ,		lowerCamelCase__=18     ,		lowerCamelCase__=30     ,		lowerCamelCase__=400     ,		lowerCamelCase__=True     ,		lowerCamelCase__=None     ,		lowerCamelCase__=True     ,		lowerCamelCase__=None     ,		lowerCamelCase__=True     ,		lowerCamelCase__=[0.5, 0.5, 0.5]     ,		lowerCamelCase__=[0.5, 0.5, 0.5]     ,		)       -> Dict:



							'''simple docstring'''
							__lowerCamelCase									=       size if size is not None else {'shortest_edge': 18}
							__lowerCamelCase									=       crop_size if crop_size is not None else {'height': 18, 'width': 18}
							__lowerCamelCase									=       parent
							__lowerCamelCase									=       batch_size
							__lowerCamelCase									=       num_channels
							__lowerCamelCase									=       image_size
							__lowerCamelCase									=       min_resolution
							__lowerCamelCase									=       max_resolution
							__lowerCamelCase									=       do_resize
							__lowerCamelCase									=       size
							__lowerCamelCase									=       do_center_crop
							__lowerCamelCase									=       crop_size
							__lowerCamelCase									=       do_normalize
							__lowerCamelCase									=       image_mean
							__lowerCamelCase									=       image_std






			def  lowercase_       ( self				)       -> Dict:



							'''simple docstring'''
							return {
							    "image_mean": self.image_mean,
							    "image_std": self.image_std,
							    "do_normalize": self.do_normalize,
							    "do_resize": self.do_resize,
							    "do_center_crop": self.do_center_crop,
							    "size": self.size,
							    "crop_size": self.crop_size,
							}







@require_torch
@require_vision
class        __lowerCAmelCase					(			__magic_name__     ,							unittest.TestCase					):

			"""simple docstring"""







			snake_case_  						=			LevitImageProcessor if is_vision_available() else None


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



							'''simple docstring'''
							__lowerCamelCase									=       LevitImageProcessingTester(self				)


			@property
			def  lowercase_       ( self				)       -> List[Any]:



							'''simple docstring'''
							return self.image_processor_tester.prepare_image_processor_dict()


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



							'''simple docstring'''
							__lowerCamelCase									=       self.image_processing_class(**self.image_processor_dict				)
							self.assertTrue(hasattr(lowerCamelCase__     ,		'image_mean'				)				)
							self.assertTrue(hasattr(lowerCamelCase__     ,		'image_std'				)				)
							self.assertTrue(hasattr(lowerCamelCase__     ,		'do_normalize'				)				)
							self.assertTrue(hasattr(lowerCamelCase__     ,		'do_resize'				)				)
							self.assertTrue(hasattr(lowerCamelCase__     ,		'do_center_crop'				)				)
							self.assertTrue(hasattr(lowerCamelCase__     ,		'size'				)				)


			def  lowercase_       ( self				)       -> Tuple:



							'''simple docstring'''
							__lowerCamelCase									=       self.image_processing_class.from_dict(self.image_processor_dict				)
							self.assertEqual(image_processor.size     ,		{'shortest_edge': 18}				)
							self.assertEqual(image_processor.crop_size     ,		{'height': 18, 'width': 18}				)

							__lowerCamelCase									=       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				)       -> Optional[Any]:



							'''simple docstring'''
							pass


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



							'''simple docstring'''
							# Initialize image_processing
							__lowerCamelCase									=       self.image_processing_class(**self.image_processor_dict				)
							# create random PIL images
							__lowerCamelCase									=       prepare_image_inputs(self.image_processor_tester     ,		equal_resolution=lowerCamelCase__				)
							for image in image_inputs:
											self.assertIsInstance(lowerCamelCase__     ,		Image.Image				)

							# Test not batched input
							__lowerCamelCase									=       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
							__lowerCamelCase									=       image_processing(lowerCamelCase__     ,		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				)       -> Union[str, Any]:



							'''simple docstring'''
							# Initialize image_processing
							__lowerCamelCase									=       self.image_processing_class(**self.image_processor_dict				)
							# create random numpy tensors
							__lowerCamelCase									=       prepare_image_inputs(self.image_processor_tester     ,		equal_resolution=lowerCamelCase__     ,		numpify=lowerCamelCase__				)
							for image in image_inputs:
											self.assertIsInstance(lowerCamelCase__     ,		np.ndarray				)

							# Test not batched input
							__lowerCamelCase									=       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
							__lowerCamelCase									=       image_processing(lowerCamelCase__     ,		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				)       -> Optional[Any]:



							'''simple docstring'''
							# Initialize image_processing
							__lowerCamelCase									=       self.image_processing_class(**self.image_processor_dict				)
							# create random PyTorch tensors
							__lowerCamelCase									=       prepare_image_inputs(self.image_processor_tester     ,		equal_resolution=lowerCamelCase__     ,		torchify=lowerCamelCase__				)
							for image in image_inputs:
											self.assertIsInstance(lowerCamelCase__     ,		torch.Tensor				)

							# Test not batched input
							__lowerCamelCase									=       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
							__lowerCamelCase									=       image_processing(lowerCamelCase__     ,		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'],
							    )     ,		)








from string import ascii_uppercase

__A								=       {str(ord(c) - 55): c for c in ascii_uppercase}







def      lowerCamelCase_						(			UpperCamelCase__							: int					,	UpperCamelCase__							: int )	->			str:





				"""simple docstring"""


				if isinstance(UpperCamelCase__					,	UpperCamelCase__ ):
								raise TypeError('int() can\'t convert non-string with explicit base' )
				if num < 0:
								raise ValueError('parameter must be positive int' )
				if isinstance(UpperCamelCase__					,	UpperCamelCase__ ):
								raise TypeError('\'str\' object cannot be interpreted as an integer' )
				if isinstance(UpperCamelCase__					,	UpperCamelCase__ ):
								raise TypeError('\'float\' object cannot be interpreted as an integer' )
				if base in (0, 1):
								raise ValueError('base must be >= 2' )
				if base > 36:
								raise ValueError('base must be <= 36' )
				__lowerCamelCase									=       ''
				__lowerCamelCase									=       0
				__lowerCamelCase									=       0
				while div != 1:
								__lowerCamelCase			,		__lowerCamelCase									=       divmod(UpperCamelCase__					,	UpperCamelCase__ )
								if base >= 11 and 9 < mod < 36:
												__lowerCamelCase									=       ALPHABET_VALUES[str(UpperCamelCase__ )]
								else:
												__lowerCamelCase									=       str(UpperCamelCase__ )
								new_value += actual_value
								__lowerCamelCase									=       num // base
								__lowerCamelCase									=       div
								if div == 0:
												return str(new_value[::-1] )
								elif div == 1:
												new_value += str(UpperCamelCase__ )
												return str(new_value[::-1] )

				return new_value[::-1]


if __name__ == "__main__":
					import doctest

					doctest.testmod()

					for base in range(2, 37):
										for num in range(10_00):
															assert int(decimal_to_any(num, base), base) == num, (
															    num,
															    base,
															    decimal_to_any(num, base),
															    int(decimal_to_any(num, base), base),
															)


