
"""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, prepare_image_inputs


if is_torch_available():
		import torch

if is_vision_available():
		from PIL import Image

		from transformers import MobileViTImageProcessor



class 			lowerCAmelCase_		(unittest.TestCase						):


				"""simple docstring"""



				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__=None     , SCREAMING_SNAKE_CASE__=True     , )      ->	List[Any]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: List[str]     =     size if size is not None else {"""shortest_edge""": 20}
											SCREAMING_SNAKE_CASE__		: List[Any]     =     crop_size if crop_size is not None else {"""height""": 18, """width""": 18}
											SCREAMING_SNAKE_CASE__		: Any     =     parent
											SCREAMING_SNAKE_CASE__		: List[str]     =     batch_size
											SCREAMING_SNAKE_CASE__		: Dict     =     num_channels
											SCREAMING_SNAKE_CASE__		: List[Any]     =     image_size
											SCREAMING_SNAKE_CASE__		: Dict     =     min_resolution
											SCREAMING_SNAKE_CASE__		: Dict     =     max_resolution
											SCREAMING_SNAKE_CASE__		: Optional[int]     =     do_resize
											SCREAMING_SNAKE_CASE__		: Optional[Any]     =     size
											SCREAMING_SNAKE_CASE__		: Union[str, Any]     =     do_center_crop
											SCREAMING_SNAKE_CASE__		: Optional[Any]     =     crop_size
											SCREAMING_SNAKE_CASE__		: List[str]     =     do_flip_channel_order



				def 			__magic_name__					(self					)      ->	int:



											"""simple docstring"""




											return {
											    "do_resize": self.do_resize,
											    "size": self.size,
											    "do_center_crop": self.do_center_crop,
											    "crop_size": self.crop_size,
											    "do_flip_channel_order": self.do_flip_channel_order,
											}






@require_torch
@require_vision
class 			lowerCAmelCase_		(a__				,      unittest.TestCase						):


				"""simple docstring"""



				__UpperCamelCase   :		str       =     MobileViTImageProcessor if is_vision_available() else None



				def 			__magic_name__					(self					)      ->	int:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: Optional[Any]     =     MobileViTImageProcessingTester(self					)



				@property
				def 			__magic_name__					(self					)      ->	Any:



											"""simple docstring"""




											return self.image_processor_tester.prepare_image_processor_dict()



				def 			__magic_name__					(self					)      ->	Optional[Any]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: Optional[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_center_crop"""					)					)
											self.assertTrue(hasattr(SCREAMING_SNAKE_CASE__     , """center_crop"""					)					)
											self.assertTrue(hasattr(SCREAMING_SNAKE_CASE__     , """do_flip_channel_order"""					)					)



				def 			__magic_name__					(self					)      ->	Tuple:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: Dict     =     self.image_processing_class.from_dict(self.image_processor_dict					)
											self.assertEqual(image_processor.size     , {"""shortest_edge""": 20}					)
											self.assertEqual(image_processor.crop_size     , {"""height""": 18, """width""": 18}					)

											SCREAMING_SNAKE_CASE__		: Optional[Any]     =     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 			__magic_name__					(self					)      ->	Union[str, Any]:



											"""simple docstring"""




											pass



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



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: List[str]     =     self.image_processing_class(**self.image_processor_dict					)
											# create random PIL images
											SCREAMING_SNAKE_CASE__		: List[str]     =     prepare_image_inputs(self.image_processor_tester     , equal_resolution=SCREAMING_SNAKE_CASE__					)
											for image in image_inputs:
																		self.assertIsInstance(SCREAMING_SNAKE_CASE__     , Image.Image					)

											# Test not batched input
											SCREAMING_SNAKE_CASE__		: Dict     =     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
											SCREAMING_SNAKE_CASE__		: List[str]     =     image_processing(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.crop_size["""height"""],
											        self.image_processor_tester.crop_size["""width"""],
											    )     , )



				def 			__magic_name__					(self					)      ->	int:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: Optional[int]     =     self.image_processing_class(**self.image_processor_dict					)
											# create random numpy tensors
											SCREAMING_SNAKE_CASE__		: Tuple     =     prepare_image_inputs(self.image_processor_tester     , 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
											SCREAMING_SNAKE_CASE__		: Optional[Any]     =     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
											SCREAMING_SNAKE_CASE__		: Optional[int]     =     image_processing(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.crop_size["""height"""],
											        self.image_processor_tester.crop_size["""width"""],
											    )     , )



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



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: List[Any]     =     self.image_processing_class(**self.image_processor_dict					)
											# create random PyTorch tensors
											SCREAMING_SNAKE_CASE__		: Any     =     prepare_image_inputs(self.image_processor_tester     , 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
											SCREAMING_SNAKE_CASE__		: 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
											SCREAMING_SNAKE_CASE__		: Optional[Any]     =     image_processing(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.crop_size["""height"""],
											        self.image_processor_tester.crop_size["""width"""],
											    )     , )






"""simple docstring"""




def lowercase_						(     _snake_case		):
							if divisor % 5 == 0 or divisor % 2 == 0:
														return 0
							SCREAMING_SNAKE_CASE__		: List[str]     =     1
							SCREAMING_SNAKE_CASE__		: List[Any]     =     1
							while repunit:
														SCREAMING_SNAKE_CASE__		: Dict     =     (10 * repunit + 1) % divisor
														repunit_index += 1
							return repunit_index

def lowercase_						(     _snake_case = 1_000_000		):
							SCREAMING_SNAKE_CASE__		: int     =     limit - 1
							if divisor % 2 == 0:
														divisor += 1
							while least_divisible_repunit(_snake_case		) <= limit:
														divisor += 2
							return divisor


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




