


'''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 PoolFormerImageProcessor




class 		a__    (							unittest.TestCase  ):







							def __init__(		self ,   lowerCamelCase_ ,   lowerCamelCase_=7 ,   lowerCamelCase_=3 ,   lowerCamelCase_=30 ,   lowerCamelCase_=4_00 ,   lowerCamelCase_=True ,   lowerCamelCase_=None ,   lowerCamelCase_=0.9 ,   lowerCamelCase_=None ,   lowerCamelCase_=True ,   lowerCamelCase_=[0.5, 0.5, 0.5] ,   lowerCamelCase_=[0.5, 0.5, 0.5] ,   )	->							Tuple:
														lowerCAmelCase__	       =     size if size is not None else {'''shortest_edge''': 30}
														lowerCAmelCase__	       =     crop_size if crop_size is not None else {'''height''': 30, '''width''': 30}
														lowerCAmelCase__	       =     parent
														lowerCAmelCase__	       =     batch_size
														lowerCAmelCase__	       =     num_channels
														lowerCAmelCase__	       =     min_resolution
														lowerCAmelCase__	       =     max_resolution
														lowerCAmelCase__	       =     do_resize_and_center_crop
														lowerCAmelCase__	       =     size
														lowerCAmelCase__	       =     crop_pct
														lowerCAmelCase__	       =     crop_size
														lowerCAmelCase__	       =     do_normalize
														lowerCAmelCase__	       =     image_mean
														lowerCAmelCase__	       =     image_std







							def   __SCREAMING_SNAKE_CASE							(		self       )	->							str:
														return {
														    "size": self.size,
														    "do_resize_and_center_crop": self.do_resize_and_center_crop,
														    "crop_pct": self.crop_pct,
														    "crop_size": self.crop_size,
														    "do_normalize": self.do_normalize,
														    "image_mean": self.image_mean,
														    "image_std": self.image_std,
														}




@require_torch
@require_vision
class 		a__    (							a__    ,    unittest.TestCase  ):
							lowercase__      :       Any     						=				PoolFormerImageProcessor if is_vision_available() else None







							def   __SCREAMING_SNAKE_CASE							(		self       )	->							List[str]:
														lowerCAmelCase__	       =     PoolFormerImageProcessingTester(self       )







							@property
							def   __SCREAMING_SNAKE_CASE							(		self       )	->							List[Any]:
														return self.image_processor_tester.prepare_image_processor_dict()







							def   __SCREAMING_SNAKE_CASE							(		self       )	->							List[str]:
														lowerCAmelCase__	       =     self.image_processing_class(**self.image_processor_dict       )
														self.assertTrue(hasattr(lowerCamelCase_ ,   '''do_resize_and_center_crop'''       )       )
														self.assertTrue(hasattr(lowerCamelCase_ ,   '''size'''       )       )
														self.assertTrue(hasattr(lowerCamelCase_ ,   '''crop_pct'''       )       )
														self.assertTrue(hasattr(lowerCamelCase_ ,   '''do_normalize'''       )       )
														self.assertTrue(hasattr(lowerCamelCase_ ,   '''image_mean'''       )       )
														self.assertTrue(hasattr(lowerCamelCase_ ,   '''image_std'''       )       )







							def   __SCREAMING_SNAKE_CASE							(		self       )	->							Union[str, Any]:
														lowerCAmelCase__	       =     self.image_processing_class.from_dict(self.image_processor_dict       )
														self.assertEqual(image_processor.size ,   {'''shortest_edge''': 30}       )
														self.assertEqual(image_processor.crop_size ,   {'''height''': 30, '''width''': 30}       )

														lowerCAmelCase__	       =     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   __SCREAMING_SNAKE_CASE							(		self       )	->							Optional[Any]:
														pass







							def   __SCREAMING_SNAKE_CASE							(		self       )	->							Dict:
														# Initialize image_processing
														lowerCAmelCase__	       =     self.image_processing_class(**self.image_processor_dict       )
														# create random PIL images
														lowerCAmelCase__	       =     prepare_image_inputs(self.image_processor_tester ,   equal_resolution=lowerCamelCase_       )
														for image in image_inputs:
																					self.assertIsInstance(lowerCamelCase_ ,   Image.Image       )

														# Test not batched input
														lowerCAmelCase__	       =     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
														lowerCAmelCase__	       =     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   __SCREAMING_SNAKE_CASE							(		self       )	->							List[Any]:
														# Initialize image_processing
														lowerCAmelCase__	       =     self.image_processing_class(**self.image_processor_dict       )
														# create random numpy tensors
														lowerCAmelCase__	       =     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
														lowerCAmelCase__	       =     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
														lowerCAmelCase__	       =     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   __SCREAMING_SNAKE_CASE							(		self       )	->							List[Any]:
														# Initialize image_processing
														lowerCAmelCase__	       =     self.image_processing_class(**self.image_processor_dict       )
														# create random PyTorch tensors
														lowerCAmelCase__	       =     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
														lowerCAmelCase__	       =     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
														lowerCAmelCase__	       =     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'''






def  _snake_case       (					A = 10			,   A = 22	)						->   int:
							lowerCAmelCase__	       =     range(1			,   A	)
							lowerCAmelCase__	       =     range(1			,   A	)
							return sum(
							    1 for power in powers for base in bases if len(str(base**power	)	) == power	)


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