


'''simple docstring'''




import unittest
from typing import Dict, List, Optional, Union

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 BridgeTowerImageProcessor



class  lowerCAmelCase				(				unittest.TestCase							):



	def __init__(					self ,					snake_case__ ,					snake_case__ = True ,					snake_case__ = None ,					snake_case__ = 32 ,					snake_case__ = True ,					snake_case__ = 1 / 255 ,					snake_case__ = True ,					snake_case__ = True ,					snake_case__ = [0.4_8_1_4_5_4_6_6, 0.4_5_7_8_2_7_5, 0.4_0_8_2_1_0_7_3] ,					snake_case__ = [0.2_6_8_6_2_9_5_4, 0.2_6_1_3_0_2_5_8, 0.2_7_5_7_7_7_1_1] ,					snake_case__ = True ,					snake_case__=7 ,					snake_case__=30 ,					snake_case__=400 ,					snake_case__=3 ,					):
		lowerCAmelCase					:    Tuple      							= parent
		lowerCAmelCase					:    Union[str, Any]      							= do_resize
		lowerCAmelCase					:    List[Any]      							= size if size is not None else {'shortest_edge': 288}
		lowerCAmelCase					:    str      							= size_divisor
		lowerCAmelCase					:    Optional[int]      							= do_rescale
		lowerCAmelCase					:    List[Any]      							= rescale_factor
		lowerCAmelCase					:    Tuple      							= do_normalize
		lowerCAmelCase					:    Union[str, Any]      							= do_center_crop
		lowerCAmelCase					:    str      							= image_mean
		lowerCAmelCase					:    List[str]      							= image_std
		lowerCAmelCase					:    Dict      							= do_pad
		lowerCAmelCase					:    List[Any]      							= batch_size
		lowerCAmelCase					:    Optional[int]      							= num_channels
		lowerCAmelCase					:    str      							= min_resolution
		lowerCAmelCase					:    Union[str, Any]      							= max_resolution



	def 				lowercase     (					self    ):
		return {
		    "image_mean": self.image_mean,
		    "image_std": self.image_std,
		    "do_normalize": self.do_normalize,
		    "do_resize": self.do_resize,
		    "size": self.size,
		    "size_divisor": self.size_divisor,
		}



	def 				lowercase     (					self ,					snake_case__ ,					snake_case__=False    ):
		if not batched:
			lowerCAmelCase					:    Optional[int]      							= self.size['shortest_edge']
			lowerCAmelCase					:    Union[str, Any]      							= image_inputs[0]
			if isinstance(snake_case__ ,					Image.Image    ):
				lowerCAmelCase							,   lowerCAmelCase					:    Optional[Any]      							= image.size
			else:
				lowerCAmelCase							,   lowerCAmelCase					:    Optional[Any]      							= image.shape[1], image.shape[2]
			lowerCAmelCase					:    int      							= size / min(snake_case__ ,					snake_case__    )
			if h < w:
				lowerCAmelCase							,   lowerCAmelCase					:    int      							= size, scale * w
			else:
				lowerCAmelCase							,   lowerCAmelCase					:    str      							= scale * h, size

			lowerCAmelCase					:    str      							= int((1333 / 800) * size    )
			if max(snake_case__ ,					snake_case__    ) > max_size:
				lowerCAmelCase					:    Dict      							= max_size / max(snake_case__ ,					snake_case__    )
				lowerCAmelCase					:    List[str]      							= newh * scale
				lowerCAmelCase					:    Any      							= neww * scale

			lowerCAmelCase							,   lowerCAmelCase					:    List[str]      							= int(newh + 0.5    ), int(neww + 0.5    )
			lowerCAmelCase							,   lowerCAmelCase					:    Tuple      							= (
			    newh // self.size_divisor * self.size_divisor,
			    neww // self.size_divisor * self.size_divisor,
			)

		else:
			lowerCAmelCase					:    Optional[int]      							= []
			for image in image_inputs:
				lowerCAmelCase							,   lowerCAmelCase					:    int      							= self.get_expected_values([image]    )
				expected_values.append((expected_height, expected_width)    )
			lowerCAmelCase					:    Optional[Any]      							= max(snake_case__ ,					key=lambda snake_case__    : item[0]    )[0]
			lowerCAmelCase					:    str      							= max(snake_case__ ,					key=lambda snake_case__    : item[1]    )[1]

		return expected_height, expected_width



@require_torch
@require_vision
class  lowerCAmelCase				(				a      ,				unittest.TestCase							):
	_lowerCamelCase   :					int			      = BridgeTowerImageProcessor if is_vision_available() else None



	def 				lowercase     (					self    ):
		lowerCAmelCase					:    Dict      							= BridgeTowerImageProcessingTester(self    )



	@property
	def 				lowercase     (					self    ):
		return self.image_processor_tester.prepare_image_processor_dict()



	def 				lowercase     (					self    ):
		lowerCAmelCase					:    Dict      							= self.image_processing_class(**self.image_processor_dict    )
		self.assertTrue(hasattr(snake_case__ ,					'image_mean'    )    )
		self.assertTrue(hasattr(snake_case__ ,					'image_std'    )    )
		self.assertTrue(hasattr(snake_case__ ,					'do_normalize'    )    )
		self.assertTrue(hasattr(snake_case__ ,					'do_resize'    )    )
		self.assertTrue(hasattr(snake_case__ ,					'size'    )    )
		self.assertTrue(hasattr(snake_case__ ,					'size_divisor'    )    )



	def 				lowercase     (					self    ):
		pass



	def 				lowercase     (					self    ):
		# Initialize image processor
		lowerCAmelCase					:    Dict      							= self.image_processing_class(**self.image_processor_dict    )
		# create random PIL images
		lowerCAmelCase					:    int      							= prepare_image_inputs(self.image_processor_tester ,					equal_resolution=snake_case__    )
		for image in image_inputs:
			self.assertIsInstance(snake_case__ ,					Image.Image    )

		# Test not batched input
		lowerCAmelCase					:    Any      							= image_processing(image_inputs[0] ,					return_tensors='pt'    ).pixel_values

		lowerCAmelCase							,   lowerCAmelCase					:    Tuple      							= self.image_processor_tester.get_expected_values(snake_case__    )
		self.assertEqual(
		    encoded_images.shape ,					(1, self.image_processor_tester.num_channels, expected_height, expected_width) ,					)

		# Test batched
		lowerCAmelCase					:    Union[str, Any]      							= image_processing(snake_case__ ,					return_tensors='pt'    ).pixel_values

		lowerCAmelCase							,   lowerCAmelCase					:    Optional[int]      							= self.image_processor_tester.get_expected_values(snake_case__ ,					batched=snake_case__    )
		self.assertEqual(
		    encoded_images.shape ,					(
		        self.image_processor_tester.batch_size,
		        self.image_processor_tester.num_channels,
		        expected_height,
		        expected_width,
		    ) ,					)



	def 				lowercase     (					self    ):
		# Initialize image processor
		lowerCAmelCase					:    Union[str, Any]      							= self.image_processing_class(**self.image_processor_dict    )
		# create random numpy tensors
		lowerCAmelCase					:    int      							= prepare_image_inputs(self.image_processor_tester ,					equal_resolution=snake_case__ ,					numpify=snake_case__    )
		for image in image_inputs:
			self.assertIsInstance(snake_case__ ,					np.ndarray    )

		# Test not batched input
		lowerCAmelCase					:    int      							= image_processing(image_inputs[0] ,					return_tensors='pt'    ).pixel_values

		lowerCAmelCase							,   lowerCAmelCase					:    Any      							= self.image_processor_tester.get_expected_values(snake_case__    )
		self.assertEqual(
		    encoded_images.shape ,					(1, self.image_processor_tester.num_channels, expected_height, expected_width) ,					)

		# Test batched
		lowerCAmelCase					:    Optional[int]      							= image_processing(snake_case__ ,					return_tensors='pt'    ).pixel_values

		lowerCAmelCase							,   lowerCAmelCase					:    Any      							= self.image_processor_tester.get_expected_values(snake_case__ ,					batched=snake_case__    )
		self.assertEqual(
		    encoded_images.shape ,					(
		        self.image_processor_tester.batch_size,
		        self.image_processor_tester.num_channels,
		        expected_height,
		        expected_width,
		    ) ,					)



	def 				lowercase     (					self    ):
		# Initialize image processor
		lowerCAmelCase					:    Optional[int]      							= self.image_processing_class(**self.image_processor_dict    )
		# create random PyTorch tensors
		lowerCAmelCase					:    Union[str, Any]      							= prepare_image_inputs(self.image_processor_tester ,					equal_resolution=snake_case__ ,					torchify=snake_case__    )
		for image in image_inputs:
			self.assertIsInstance(snake_case__ ,					torch.Tensor    )

		# Test not batched input
		lowerCAmelCase					:    Dict      							= image_processing(image_inputs[0] ,					return_tensors='pt'    ).pixel_values

		lowerCAmelCase							,   lowerCAmelCase					:    int      							= self.image_processor_tester.get_expected_values(snake_case__    )
		self.assertEqual(
		    encoded_images.shape ,					(1, self.image_processor_tester.num_channels, expected_height, expected_width) ,					)

		# Test batched
		lowerCAmelCase					:    Optional[Any]      							= image_processing(snake_case__ ,					return_tensors='pt'    ).pixel_values

		lowerCAmelCase							,   lowerCAmelCase					:    Union[str, Any]      							= self.image_processor_tester.get_expected_values(snake_case__ ,					batched=snake_case__    )
		self.assertEqual(
		    encoded_images.shape ,					(
		        self.image_processor_tester.batch_size,
		        self.image_processor_tester.num_channels,
		        expected_height,
		        expected_width,
		    ) ,					)




'''simple docstring'''




_lowerCAmelCase  :		List[str]		     =	{str(digit): digit**5 for digit in range(10)}

def 			__UpperCamelCase    (    _A    :				int				)    ->      int:




	"""simple docstring"""





	return sum(DIGITS_FIFTH_POWER[digit] for digit in str(_A				)				)

def 			__UpperCamelCase    (    )    ->      int:




	"""simple docstring"""





	return sum(
	    number
	    for number in range(10_00					,   1_00_00_00				)
	    if number == digits_fifth_powers_sum(_A				)				)


if __name__ == "__main__":
				print(solution())
