
'''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 				lowerCAmelCase__     (						unittest.TestCase  ):






					def __init__(     self       ,							__SCREAMING_SNAKE_CASE       ,							__SCREAMING_SNAKE_CASE=7       ,							__SCREAMING_SNAKE_CASE=3       ,							__SCREAMING_SNAKE_CASE=18       ,							__SCREAMING_SNAKE_CASE=30       ,							__SCREAMING_SNAKE_CASE=4_00       ,							__SCREAMING_SNAKE_CASE=True       ,							__SCREAMING_SNAKE_CASE=None       ,							__SCREAMING_SNAKE_CASE=True       ,							__SCREAMING_SNAKE_CASE=False       ,							__SCREAMING_SNAKE_CASE=[0.48_145_466, 0.4_578_275, 0.40_821_073]       ,							__SCREAMING_SNAKE_CASE=[0.26_862_954, 0.26_130_258, 0.27_577_711]       ,							__SCREAMING_SNAKE_CASE=True       ,							):


											"""simple docstring"""





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






					def 			_snake_case					(     self	):


											"""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 			_snake_case					(     self       ,							__SCREAMING_SNAKE_CASE=False       ,							__SCREAMING_SNAKE_CASE=False       ,							__SCREAMING_SNAKE_CASE=False	):


											"""simple docstring"""





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

											if equal_resolution:
																	lowercase_			:  Union[str, Any]									= []
																	for i in range(self.batch_size	):
																							image_inputs.append(
																							    np.random.randint(
																							        2_55       ,							size=(self.num_channels, self.max_resolution, self.max_resolution)       ,							dtype=np.uinta	)	)
											else:
																	lowercase_			:  Dict									= []
																	for i in range(self.batch_size	):
																							lowercase_		,				lowercase_			:  int									= np.random.choice(np.arange(self.min_resolution       ,							self.max_resolution	)       ,							2	)
																							image_inputs.append(np.random.randint(2_55       ,							size=(self.num_channels, width, height)       ,							dtype=np.uinta	)	)

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

											if torchify:
																	lowercase_			:  Tuple									= [torch.from_numpy(__SCREAMING_SNAKE_CASE	) for x in image_inputs]

											return image_inputs







@require_torch
@require_vision
class 				lowerCAmelCase__     (						lowerCamelCase_					,		unittest.TestCase  ):
					lowerCAmelCase_       =  BlipImageProcessor if is_vision_available() else None






					def 			_snake_case					(     self	):


											"""simple docstring"""





											lowercase_			:  List[str]									= BlipImageProcessingTester(self	)






					@property
					def 			_snake_case					(     self	):


											"""simple docstring"""





											return self.image_processor_tester.prepare_image_processor_dict()






					def 			_snake_case					(     self	):


											"""simple docstring"""





											lowercase_			:  Any									= self.image_processing_class(**self.image_processor_dict	)
											self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE       ,							'''do_resize'''	)	)
											self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE       ,							'''size'''	)	)
											self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE       ,							'''do_normalize'''	)	)
											self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE       ,							'''image_mean'''	)	)
											self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE       ,							'''image_std'''	)	)
											self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE       ,							'''do_convert_rgb'''	)	)






					def 			_snake_case					(     self	):


											"""simple docstring"""





											pass






					def 			_snake_case					(     self	):


											"""simple docstring"""





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

											# Test not batched input
											lowercase_			:  Tuple									= 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
											lowercase_			:  Union[str, Any]									= image_processor(__SCREAMING_SNAKE_CASE       ,							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 			_snake_case					(     self	):


											"""simple docstring"""





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

											# Test not batched input
											lowercase_			:  Union[str, Any]									= 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
											lowercase_			:  List[Any]									= image_processor(__SCREAMING_SNAKE_CASE       ,							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 			_snake_case					(     self	):


											"""simple docstring"""





											lowercase_			:  str									= self.image_processing_class(**self.image_processor_dict	)
											# create random PyTorch tensors
											lowercase_			:  int									= self.image_processor_tester.prepare_inputs(equal_resolution=__SCREAMING_SNAKE_CASE       ,							torchify=__SCREAMING_SNAKE_CASE	)
											for image in image_inputs:
																	self.assertIsInstance(__SCREAMING_SNAKE_CASE       ,							torch.Tensor	)

											# Test not batched input
											lowercase_			:  Optional[Any]									= 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
											lowercase_			:  int									= image_processor(__SCREAMING_SNAKE_CASE       ,							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 				lowerCAmelCase__     (						lowerCamelCase_					,		unittest.TestCase  ):
					lowerCAmelCase_       =  BlipImageProcessor if is_vision_available() else None






					def 			_snake_case					(     self	):


											"""simple docstring"""





											lowercase_			:  Optional[int]									= BlipImageProcessingTester(self       ,							num_channels=4	)
											lowercase_			:  str									= 3






					@property
					def 			_snake_case					(     self	):


											"""simple docstring"""





											return self.image_processor_tester.prepare_image_processor_dict()






					def 			_snake_case					(     self	):


											"""simple docstring"""





											lowercase_			:  List[Any]									= self.image_processing_class(**self.image_processor_dict	)
											self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE       ,							'''do_resize'''	)	)
											self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE       ,							'''size'''	)	)
											self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE       ,							'''do_normalize'''	)	)
											self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE       ,							'''image_mean'''	)	)
											self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE       ,							'''image_std'''	)	)
											self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE       ,							'''do_convert_rgb'''	)	)






					def 			_snake_case					(     self	):


											"""simple docstring"""





											pass






					def 			_snake_case					(     self	):


											"""simple docstring"""





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

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





'''simple docstring'''







def       snake_case_	(       __SCREAMING_SNAKE_CASE      :				int = 998001							):



						"""simple docstring"""





						lowercase_			:  Dict									= 0
						for i in range(999   ,   99   ,   -1							):  # 3 digit numbers range from 999 down to 100
												for j in range(999   ,   99   ,   -1							):
																		lowercase_			:  int									= str(i * j							)
																		if product_string == product_string[::-1] and i * j < n:
																								lowercase_			:  str									= max(__SCREAMING_SNAKE_CASE   ,   i * j							)
						return answer


if __name__ == "__main__":
							print(f"""{solution() = }""")



