


"""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   _UpperCamelCase  (   unittest.TestCase		):
							'''simple docstring'''







							def __init__(     self    ,   __a    ,   __a = True    ,   __a = None    ,   __a = 32    ,   __a = True    ,   __a = 1 / 2_55    ,   __a = True    ,   __a = True    ,   __a = [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]    ,   __a = [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]    ,   __a = True    ,   __a=7    ,   __a=30    ,   __a=4_00    ,   __a=3    ,   ):
										__lowerCAmelCase				    =			parent
										__lowerCAmelCase				    =			do_resize
										__lowerCAmelCase				    =			size if size is not None else {"shortest_edge": 2_88}
										__lowerCAmelCase				    =			size_divisor
										__lowerCAmelCase				    =			do_rescale
										__lowerCAmelCase				    =			rescale_factor
										__lowerCAmelCase				    =			do_normalize
										__lowerCAmelCase				    =			do_center_crop
										__lowerCAmelCase				    =			image_mean
										__lowerCAmelCase				    =			image_std
										__lowerCAmelCase				    =			do_pad
										__lowerCAmelCase				    =			batch_size
										__lowerCAmelCase				    =			num_channels
										__lowerCAmelCase				    =			min_resolution
										__lowerCAmelCase				    =			max_resolution

							def 			snake_case				(     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 			snake_case				(     self    ,   __a    ,   __a=False	):
										if not batched:
													__lowerCAmelCase				    =			self.size["shortest_edge"]
													__lowerCAmelCase				    =			image_inputs[0]
													if isinstance(__a    ,   Image.Image	):
																__lowerCAmelCase    ,	__lowerCAmelCase				    =			image.size
													else:
																__lowerCAmelCase    ,	__lowerCAmelCase				    =			image.shape[1], image.shape[2]
													__lowerCAmelCase				    =			size / min(__a    ,   __a	)
													if h < w:
																__lowerCAmelCase    ,	__lowerCAmelCase				    =			size, scale * w
													else:
																__lowerCAmelCase    ,	__lowerCAmelCase				    =			scale * h, size

													__lowerCAmelCase				    =			int((13_33 / 8_00) * size	)
													if max(__a    ,   __a	) > max_size:
																__lowerCAmelCase				    =			max_size / max(__a    ,   __a	)
																__lowerCAmelCase				    =			newh * scale
																__lowerCAmelCase				    =			neww * scale

													__lowerCAmelCase    ,	__lowerCAmelCase				    =			int(newh + 0.5	), int(neww + 0.5	)
													__lowerCAmelCase    ,	__lowerCAmelCase				    =			(
													    newh // self.size_divisor * self.size_divisor,
													    neww // self.size_divisor * self.size_divisor,
													)

										else:
													__lowerCAmelCase				    =			[]
													for image in image_inputs:
																__lowerCAmelCase    ,	__lowerCAmelCase				    =			self.get_expected_values([image]	)
																expected_values.append((expected_height, expected_width)	)
													__lowerCAmelCase				    =			max(__a    ,   key=lambda __a	: item[0]	)[0]
													__lowerCAmelCase				    =			max(__a    ,   key=lambda __a	: item[1]	)[1]

										return expected_height, expected_width
@require_torch
@require_vision
class   _UpperCamelCase  (   lowerCAmelCase__       ,unittest.TestCase		):
							'''simple docstring'''







							__UpperCAmelCase						:    List[str]				      =BridgeTowerImageProcessor if is_vision_available() else None

							def 			snake_case				(     self	):
										__lowerCAmelCase				    =			BridgeTowerImageProcessingTester(self	)

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

							def 			snake_case				(     self	):
										__lowerCAmelCase				    =			self.image_processing_class(**self.image_processor_dict	)
										self.assertTrue(hasattr(__a    ,   "image_mean"	)	)
										self.assertTrue(hasattr(__a    ,   "image_std"	)	)
										self.assertTrue(hasattr(__a    ,   "do_normalize"	)	)
										self.assertTrue(hasattr(__a    ,   "do_resize"	)	)
										self.assertTrue(hasattr(__a    ,   "size"	)	)
										self.assertTrue(hasattr(__a    ,   "size_divisor"	)	)

							def 			snake_case				(     self	):
										pass

							def 			snake_case				(     self	):
										# Initialize image processor
										__lowerCAmelCase				    =			self.image_processing_class(**self.image_processor_dict	)
										# create random PIL images
										__lowerCAmelCase				    =			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				    =			image_processing(image_inputs[0]    ,   return_tensors="pt"	).pixel_values

										__lowerCAmelCase    ,	__lowerCAmelCase				    =			self.image_processor_tester.get_expected_values(__a	)
										self.assertEqual(
										    encoded_images.shape    ,   (1, self.image_processor_tester.num_channels, expected_height, expected_width)    ,   )

										# Test batched
										__lowerCAmelCase				    =			image_processing(__a    ,   return_tensors="pt"	).pixel_values

										__lowerCAmelCase    ,	__lowerCAmelCase				    =			self.image_processor_tester.get_expected_values(__a    ,   batched=__a	)
										self.assertEqual(
										    encoded_images.shape    ,   (
										        self.image_processor_tester.batch_size,
										        self.image_processor_tester.num_channels,
										        expected_height,
										        expected_width,
										    )    ,   )

							def 			snake_case				(     self	):
										# Initialize image processor
										__lowerCAmelCase				    =			self.image_processing_class(**self.image_processor_dict	)
										# create random numpy tensors
										__lowerCAmelCase				    =			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				    =			image_processing(image_inputs[0]    ,   return_tensors="pt"	).pixel_values

										__lowerCAmelCase    ,	__lowerCAmelCase				    =			self.image_processor_tester.get_expected_values(__a	)
										self.assertEqual(
										    encoded_images.shape    ,   (1, self.image_processor_tester.num_channels, expected_height, expected_width)    ,   )

										# Test batched
										__lowerCAmelCase				    =			image_processing(__a    ,   return_tensors="pt"	).pixel_values

										__lowerCAmelCase    ,	__lowerCAmelCase				    =			self.image_processor_tester.get_expected_values(__a    ,   batched=__a	)
										self.assertEqual(
										    encoded_images.shape    ,   (
										        self.image_processor_tester.batch_size,
										        self.image_processor_tester.num_channels,
										        expected_height,
										        expected_width,
										    )    ,   )



							def 			snake_case				(     self	):
										# Initialize image processor
										__lowerCAmelCase				    =			self.image_processing_class(**self.image_processor_dict	)
										# create random PyTorch tensors
										__lowerCAmelCase				    =			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				    =			image_processing(image_inputs[0]    ,   return_tensors="pt"	).pixel_values

										__lowerCAmelCase    ,	__lowerCAmelCase				    =			self.image_processor_tester.get_expected_values(__a	)
										self.assertEqual(
										    encoded_images.shape    ,   (1, self.image_processor_tester.num_channels, expected_height, expected_width)    ,   )

										# Test batched
										__lowerCAmelCase				    =			image_processing(__a    ,   return_tensors="pt"	).pixel_values

										__lowerCAmelCase    ,	__lowerCAmelCase				    =			self.image_processor_tester.get_expected_values(__a    ,   batched=__a	)
										self.assertEqual(
										    encoded_images.shape    ,   (
										        self.image_processor_tester.batch_size,
										        self.image_processor_tester.num_channels,
										        expected_height,
										        expected_width,
										    )    ,   )








"""simple docstring"""


def _lowerCamelCase	(		):

			'''simple docstring'''




			__lowerCAmelCase				    =			[]
			__lowerCAmelCase				    =			1

			while len(_UpperCamelCase      ) < 1e6:
						constant.append(str(_UpperCamelCase      )      )
						i += 1

			__lowerCAmelCase				    =			"".join(_UpperCamelCase      )

			return (
			    int(constant[0]      )
			    * int(constant[9]      )
			    * int(constant[99]      )
			    * int(constant[999]      )
			    * int(constant[9999]      )
			    * int(constant[9_9999]      )
			    * int(constant[99_9999]      )
			)


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




