


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 DeiTImageProcessor





class    _a				(							unittest.TestCase):




	def __init__(   self		:						List[Any]						,   _SCREAMING_SNAKE_CASE		:						int						,   _SCREAMING_SNAKE_CASE		:						Optional[int]=7						,   _SCREAMING_SNAKE_CASE		:						Optional[Any]=3						,   _SCREAMING_SNAKE_CASE		:						str=18						,   _SCREAMING_SNAKE_CASE		:						Union[str, Any]=30						,   _SCREAMING_SNAKE_CASE		:						Optional[int]=400						,   _SCREAMING_SNAKE_CASE		:						List[Any]=True						,   _SCREAMING_SNAKE_CASE		:						Any=None						,   _SCREAMING_SNAKE_CASE		:						Optional[int]=True						,   _SCREAMING_SNAKE_CASE		:						Optional[int]=None						,   _SCREAMING_SNAKE_CASE		:						Tuple=True						,   _SCREAMING_SNAKE_CASE		:						Dict=[0.5, 0.5, 0.5]						,   _SCREAMING_SNAKE_CASE		:						str=[0.5, 0.5, 0.5]						,   )->			Dict:
			lowerCAmelCase__  :     Optional[Any]       	=   size if size is not None else {'''height''': 20, '''width''': 20}
			lowerCAmelCase__  :     str       	=   crop_size if crop_size is not None else {'''height''': 18, '''width''': 18}

			lowerCAmelCase__  :     int       	=   parent
			lowerCAmelCase__  :     Union[str, Any]       	=   batch_size
			lowerCAmelCase__  :     List[str]       	=   num_channels
			lowerCAmelCase__  :     Any       	=   image_size
			lowerCAmelCase__  :     Any       	=   min_resolution
			lowerCAmelCase__  :     Dict       	=   max_resolution
			lowerCAmelCase__  :     List[Any]       	=   do_resize
			lowerCAmelCase__  :     Union[str, Any]       	=   size
			lowerCAmelCase__  :     Dict       	=   do_center_crop
			lowerCAmelCase__  :     List[str]       	=   crop_size
			lowerCAmelCase__  :     int       	=   do_normalize
			lowerCAmelCase__  :     Dict       	=   image_mean
			lowerCAmelCase__  :     Any       	=   image_std




	def 				UpperCAmelCase__(   self		:						Optional[Any]						)->			Dict:
			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,
			}





@require_torch
@require_vision
class    _a				(							snake_case__	,		unittest.TestCase):
	_a    :    Optional[int]        =				DeiTImageProcessor if is_vision_available() else None
	_a    :    List[Any]        =				True




	def 				UpperCAmelCase__(   self		:						Any						)->			List[str]:
			lowerCAmelCase__  :     Union[str, Any]       	=   DeiTImageProcessingTester(self						)




	@property
	def 				UpperCAmelCase__(   self		:						Any						)->			List[Any]:
			return self.image_processor_tester.prepare_image_processor_dict()




	def 				UpperCAmelCase__(   self		:						List[Any]						)->			List[str]:
			lowerCAmelCase__  :     List[str]       	=   self.image_processing_class(**self.image_processor_dict						)
			self.assertTrue(hasattr(_A						,   '''do_resize'''						)						)
			self.assertTrue(hasattr(_A						,   '''size'''						)						)
			self.assertTrue(hasattr(_A						,   '''do_center_crop'''						)						)
			self.assertTrue(hasattr(_A						,   '''center_crop'''						)						)
			self.assertTrue(hasattr(_A						,   '''do_normalize'''						)						)
			self.assertTrue(hasattr(_A						,   '''image_mean'''						)						)
			self.assertTrue(hasattr(_A						,   '''image_std'''						)						)




	def 				UpperCAmelCase__(   self		:						List[Any]						)->			Optional[int]:
			lowerCAmelCase__  :     Optional[Any]       	=   self.image_processing_class.from_dict(self.image_processor_dict						)
			self.assertEqual(image_processor.size						,   {'''height''': 20, '''width''': 20}						)
			self.assertEqual(image_processor.crop_size						,   {'''height''': 18, '''width''': 18}						)

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




	def 				UpperCAmelCase__(   self		:						int						)->			int:
			pass




	def 				UpperCAmelCase__(   self		:						int						)->			List[Any]:
			lowerCAmelCase__  :     Tuple       	=   self.image_processing_class(**self.image_processor_dict						)
			# create random PIL images
			lowerCAmelCase__  :     List[str]       	=   prepare_image_inputs(self.image_processor_tester						,   equal_resolution=_A						)
			for image in image_inputs:
					self.assertIsInstance(_A						,   Image.Image						)

			# Test not batched input
			lowerCAmelCase__  :     Tuple       	=   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__  :     int       	=   image_processing(_A						,   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 				UpperCAmelCase__(   self		:						Union[str, Any]						)->			Optional[int]:
			lowerCAmelCase__  :     Optional[int]       	=   self.image_processing_class(**self.image_processor_dict						)
			# create random numpy tensors
			lowerCAmelCase__  :     Dict       	=   prepare_image_inputs(self.image_processor_tester						,   equal_resolution=_A						,   numpify=_A						)
			for image in image_inputs:
					self.assertIsInstance(_A						,   np.ndarray						)

			# Test not batched input
			lowerCAmelCase__  :     Tuple       	=   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__  :     Union[str, Any]       	=   image_processing(_A						,   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 				UpperCAmelCase__(   self		:						str						)->			Optional[Any]:
			lowerCAmelCase__  :     int       	=   self.image_processing_class(**self.image_processor_dict						)
			# create random PyTorch tensors
			lowerCAmelCase__  :     List[Any]       	=   prepare_image_inputs(self.image_processor_tester						,   equal_resolution=_A						,   torchify=_A						)
			for image in image_inputs:
					self.assertIsInstance(_A						,   torch.Tensor						)

			# Test not batched input
			lowerCAmelCase__  :     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
			lowerCAmelCase__  :     int       	=   image_processing(_A						,   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'''],
			    )						,   )










import decimal







def       _a (		):
					__lowerCAmelCase							  =			0
					__lowerCAmelCase							  =			decimal.Context(prec=1_05	)
					for i in range(2 , 1_00	):
										__lowerCAmelCase							  =			decimal.Decimal(SCREAMING_SNAKE_CASE_	)
										__lowerCAmelCase							  =			number.sqrt(SCREAMING_SNAKE_CASE_	)
										if len(str(SCREAMING_SNAKE_CASE_	)	) > 1:
															answer += int(str(SCREAMING_SNAKE_CASE_	)[0]	)
															__lowerCAmelCase							  =			str(SCREAMING_SNAKE_CASE_	)[2:1_01]
															answer += sum(int(SCREAMING_SNAKE_CASE_	) for x in sqrt_number_str	)
					return answer


if __name__ == "__main__":
					import doctest

					doctest.testmod()
					print(f'''{solution() = }''')




