





"""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 LevitImageProcessor






class 						__snake_case   (						unittest.TestCase	):





 """simple docstring"""


 def __init__(       self   ,		__lowerCamelCase   ,		__lowerCamelCase=7   ,		__lowerCamelCase=3   ,		__lowerCamelCase=18   ,		__lowerCamelCase=30   ,		__lowerCamelCase=400   ,		__lowerCamelCase=True   ,		__lowerCamelCase=None   ,		__lowerCamelCase=True   ,		__lowerCamelCase=None   ,		__lowerCamelCase=True   ,		__lowerCamelCase=[0.5, 0.5, 0.5]   ,		__lowerCamelCase=[0.5, 0.5, 0.5]   ,		):



     '''simple docstring'''




     __A       :		Union[str, Any]							=	size if size is not None else {'''shortest_edge''': 18}
     __A       :		Optional[Any]							=	crop_size if crop_size is not None else {'''height''': 18, '''width''': 18}
     __A       :		str							=	parent
     __A       :		str							=	batch_size
     __A       :		Union[str, Any]							=	num_channels
     __A       :		List[str]							=	image_size
     __A       :		Any							=	min_resolution
     __A       :		List[str]							=	max_resolution
     __A       :		Any							=	do_resize
     __A       :		Dict							=	size
     __A       :		Any							=	do_center_crop
     __A       :		int							=	crop_size
     __A       :		List[str]							=	do_normalize
     __A       :		int							=	image_mean
     __A       :		List[str]							=	image_std







 def    UpperCamelCase__(       self    ):



     '''simple docstring'''




     return {
         "image_mean": self.image_mean,
         "image_std": self.image_std,
         "do_normalize": self.do_normalize,
         "do_resize": self.do_resize,
         "do_center_crop": self.do_center_crop,
         "size": self.size,
         "crop_size": self.crop_size,
     }






@require_torch
@require_vision
class 						__snake_case   (						SCREAMING_SNAKE_CASE__				,				unittest.TestCase	):





 """simple docstring"""


 _lowerCamelCase								=	LevitImageProcessor if is_vision_available() else None

 def    UpperCamelCase__(       self    ):



     '''simple docstring'''




     __A       :		List[Any]							=	LevitImageProcessingTester(self    )

 @property
 def    UpperCamelCase__(       self    ):



     '''simple docstring'''




     return self.image_processor_tester.prepare_image_processor_dict()

 def    UpperCamelCase__(       self    ):



     '''simple docstring'''




     __A       :		Tuple							=	self.image_processing_class(**self.image_processor_dict    )
     self.assertTrue(hasattr(__lowerCamelCase   ,		'''image_mean'''    )    )
     self.assertTrue(hasattr(__lowerCamelCase   ,		'''image_std'''    )    )
     self.assertTrue(hasattr(__lowerCamelCase   ,		'''do_normalize'''    )    )
     self.assertTrue(hasattr(__lowerCamelCase   ,		'''do_resize'''    )    )
     self.assertTrue(hasattr(__lowerCamelCase   ,		'''do_center_crop'''    )    )
     self.assertTrue(hasattr(__lowerCamelCase   ,		'''size'''    )    )

 def    UpperCamelCase__(       self    ):



     '''simple docstring'''




     __A       :		Union[str, Any]							=	self.image_processing_class.from_dict(self.image_processor_dict    )
     self.assertEqual(image_processor.size   ,		{'''shortest_edge''': 18}    )
     self.assertEqual(image_processor.crop_size   ,		{'''height''': 18, '''width''': 18}    )

     __A       :		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    UpperCamelCase__(       self    ):



     '''simple docstring'''




     pass

 def    UpperCamelCase__(       self    ):



     '''simple docstring'''




     __A       :		int							=	self.image_processing_class(**self.image_processor_dict    )
     # create random PIL images
     __A       :		int							=	prepare_image_inputs(self.image_processor_tester   ,		equal_resolution=__lowerCamelCase    )
     for image in image_inputs:
         self.assertIsInstance(__lowerCamelCase   ,		Image.Image    )

     # Test not batched input
     __A       :		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
     __A       :		Dict							=	image_processing(__lowerCamelCase   ,		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    ):



     '''simple docstring'''




     __A       :		List[Any]							=	self.image_processing_class(**self.image_processor_dict    )
     # create random numpy tensors
     __A       :		List[Any]							=	prepare_image_inputs(self.image_processor_tester   ,		equal_resolution=__lowerCamelCase   ,		numpify=__lowerCamelCase    )
     for image in image_inputs:
         self.assertIsInstance(__lowerCamelCase   ,		np.ndarray    )

     # Test not batched input
     __A       :		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
     __A       :		Union[str, Any]							=	image_processing(__lowerCamelCase   ,		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    ):



     '''simple docstring'''




     __A       :		Any							=	self.image_processing_class(**self.image_processor_dict    )
     # create random PyTorch tensors
     __A       :		List[str]							=	prepare_image_inputs(self.image_processor_tester   ,		equal_resolution=__lowerCamelCase   ,		torchify=__lowerCamelCase    )
     for image in image_inputs:
         self.assertIsInstance(__lowerCamelCase   ,		torch.Tensor    )

     # Test not batched input
     __A       :		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
     __A       :		Dict							=	image_processing(__lowerCamelCase   ,		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"""



from collections import defaultdict
from math import gcd







def 						__lowercase	(  snake_case_    :    int = 1500000		)  ->int:



    '''simple docstring'''







    __A       :		defaultdict							=	defaultdict(snake_case_		)
    __A       :		Any							=	2
    while 2 * euclid_m * (euclid_m + 1) <= limit:
        for euclid_n in range((euclid_m % 2) + 1							,snake_case_							,2		):
            if gcd(snake_case_							,snake_case_		) > 1:
                continue
            __A       :		List[Any]							=	2 * euclid_m * (euclid_m + euclid_n)
            for perimeter in range(snake_case_							,limit + 1							,snake_case_		):
                frequencies[perimeter] += 1
        euclid_m += 1
    return sum(1 for frequency in frequencies.values() if frequency == 1		)


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




