






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				,		_UpperCamelCase				,		_UpperCamelCase=7				,		_UpperCamelCase=3				,		_UpperCamelCase=1_8				,		_UpperCamelCase=3_0				,		_UpperCamelCase=4_0_0				,		_UpperCamelCase=True				,		_UpperCamelCase=None				,		_UpperCamelCase=True				,		_UpperCamelCase=None				,		_UpperCamelCase=True				,		)	->							Optional[int]:
							UpperCAmelCase_    :      Optional[int]            =						size if size is not None else {'shortest_edge': 2_0}
							UpperCAmelCase_    :      Tuple            =						crop_size if crop_size is not None else {'height': 1_8, 'width': 1_8}
							UpperCAmelCase_    :      Dict            =						parent
							UpperCAmelCase_    :      Optional[int]            =						batch_size
							UpperCAmelCase_    :      List[str]            =						num_channels
							UpperCAmelCase_    :      List[str]            =						image_size
							UpperCAmelCase_    :      str            =						min_resolution
							UpperCAmelCase_    :      Optional[int]            =						max_resolution
							UpperCAmelCase_    :      Union[str, Any]            =						do_resize
							UpperCAmelCase_    :      List[Any]            =						size
							UpperCAmelCase_    :      List[str]            =						do_center_crop
							UpperCAmelCase_    :      int            =						crop_size
							UpperCAmelCase_    :      Union[str, Any]            =						do_flip_channel_order



		def 					__UpperCAmelCase			(							self   )	->							Optional[Any]:
							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      (_snake_case ,  unittest.TestCase			):







		'''simple docstring'''



		_snake_case    :    Tuple       						=  MobileViTImageProcessor if is_vision_available() else None



		def 					__UpperCAmelCase			(							self   )	->							int:
							UpperCAmelCase_    :      int            =						MobileViTImageProcessingTester(self   )



		@property
		def 					__UpperCAmelCase			(							self   )	->							Union[str, Any]:
							return self.image_processor_tester.prepare_image_processor_dict()



		def 					__UpperCAmelCase			(							self   )	->							str:
							UpperCAmelCase_    :      List[str]            =						self.image_processing_class(**self.image_processor_dict   )
							self.assertTrue(hasattr(_UpperCamelCase				,		'do_resize'   )   )
							self.assertTrue(hasattr(_UpperCamelCase				,		'size'   )   )
							self.assertTrue(hasattr(_UpperCamelCase				,		'do_center_crop'   )   )
							self.assertTrue(hasattr(_UpperCamelCase				,		'center_crop'   )   )
							self.assertTrue(hasattr(_UpperCamelCase				,		'do_flip_channel_order'   )   )



		def 					__UpperCAmelCase			(							self   )	->							List[str]:
							UpperCAmelCase_    :      Optional[Any]            =						self.image_processing_class.from_dict(self.image_processor_dict   )
							self.assertEqual(image_processor.size				,		{'shortest_edge': 2_0}   )
							self.assertEqual(image_processor.crop_size				,		{'height': 1_8, 'width': 1_8}   )

							UpperCAmelCase_    :      str            =						self.image_processing_class.from_dict(self.image_processor_dict				,		size=4_2				,		crop_size=8_4   )
							self.assertEqual(image_processor.size				,		{'shortest_edge': 4_2}   )
							self.assertEqual(image_processor.crop_size				,		{'height': 8_4, 'width': 8_4}   )



		def 					__UpperCAmelCase			(							self   )	->							List[str]:
							pass



		def 					__UpperCAmelCase			(							self   )	->							Tuple:
							# Initialize image_processing
							UpperCAmelCase_    :      Any            =						self.image_processing_class(**self.image_processor_dict   )
							# create random PIL images
							UpperCAmelCase_    :      Tuple            =						prepare_image_inputs(self.image_processor_tester				,		equal_resolution=_UpperCamelCase   )
							for image in image_inputs:
												self.assertIsInstance(_UpperCamelCase				,		Image.Image   )

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

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

							# Test not batched input
							UpperCAmelCase_    :      Union[str, 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
							UpperCAmelCase_    :      Union[str, Any]            =						image_processing(_UpperCamelCase				,		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     a__ (				snake_case__				)						->					bool:
			lowerCamelCase			      =					(1 + 24 * n) ** 0.5
			return ((1 + root) / 6) % 1 == 0



def     a__ (				snake_case__ = 50_00				)						->					int:
			lowerCamelCase			      =					[(i * (3 * i - 1)) // 2 for i in range(1       , snake_case__				)]
			for i, pentagonal_i in enumerate(snake_case__				):
						for j in range(snake_case__       , len(snake_case__				)				):
									lowerCamelCase			      =					pentagonal_nums[j]
									lowerCamelCase			      =					pentagonal_i + pentagonal_j
									lowerCamelCase			      =					pentagonal_j - pentagonal_i
									if is_pentagonal(snake_case__				) and is_pentagonal(snake_case__				):
												return b

			return -1


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



