



'''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      _lowerCAmelCase							(      unittest.TestCase			):


	def __init__(self	,				lowercase	,				lowercase=7	,				lowercase=3	,				lowercase=30	,				lowercase=400	,				lowercase=True	,				lowercase=None	,				lowercase=0.9	,				lowercase=None	,				lowercase=True	,				lowercase=[0.5, 0.5, 0.5]	,				lowercase=[0.5, 0.5, 0.5]	,				):
				A_     :						List[Any]     =					size if size is not None else {"""shortest_edge""": 30}
				A_     :						List[str]     =					crop_size if crop_size is not None else {"""height""": 30, """width""": 30}
				A_     :						Tuple     =					parent
				A_     :						str     =					batch_size
				A_     :						str     =					num_channels
				A_     :						Union[str, Any]     =					min_resolution
				A_     :						List[Any]     =					max_resolution
				A_     :						Optional[int]     =					do_resize_and_center_crop
				A_     :						Union[str, Any]     =					size
				A_     :						List[str]     =					crop_pct
				A_     :						List[str]     =					crop_size
				A_     :						List[Any]     =					do_normalize
				A_     :						List[Any]     =					image_mean
				A_     :						Optional[int]     =					image_std


	def    _a     (self							):
				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      _lowerCAmelCase							(      __UpperCAmelCase				,      unittest.TestCase			):
	__SCREAMING_SNAKE_CASE       :		Dict		      = PoolFormerImageProcessor if is_vision_available() else None


	def    _a     (self							):
				A_     :						Union[str, Any]     =					PoolFormerImageProcessingTester(self							)


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


	def    _a     (self							):
				A_     :						List[Any]     =					self.image_processing_class(**self.image_processor_dict							)
				self.assertTrue(hasattr(lowercase	,				"""do_resize_and_center_crop"""							)							)
				self.assertTrue(hasattr(lowercase	,				"""size"""							)							)
				self.assertTrue(hasattr(lowercase	,				"""crop_pct"""							)							)
				self.assertTrue(hasattr(lowercase	,				"""do_normalize"""							)							)
				self.assertTrue(hasattr(lowercase	,				"""image_mean"""							)							)
				self.assertTrue(hasattr(lowercase	,				"""image_std"""							)							)


	def    _a     (self							):
				A_     :						Any     =					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}							)

				A_     :						int     =					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    _a     (self							):
				pass


	def    _a     (self							):
				# Initialize image_processing
				A_     :						Union[str, Any]     =					self.image_processing_class(**self.image_processor_dict							)
				# create random PIL images
				A_     :						Tuple     =					prepare_image_inputs(self.image_processor_tester	,				equal_resolution=lowercase							)
				for image in image_inputs:
							self.assertIsInstance(lowercase	,				Image.Image							)

				# Test not batched input
				A_     :						Tuple     =					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_     :						List[Any]     =					image_processing(lowercase	,				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    _a     (self							):
				# Initialize image_processing
				A_     :						Dict     =					self.image_processing_class(**self.image_processor_dict							)
				# create random numpy tensors
				A_     :						Any     =					prepare_image_inputs(self.image_processor_tester	,				equal_resolution=lowercase	,				numpify=lowercase							)
				for image in image_inputs:
							self.assertIsInstance(lowercase	,				np.ndarray							)

				# 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_     :						Optional[Any]     =					image_processing(lowercase	,				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    _a     (self							):
				# Initialize image_processing
				A_     :						Optional[Any]     =					self.image_processing_class(**self.image_processor_dict							)
				# create random PyTorch tensors
				A_     :						Optional[Any]     =					prepare_image_inputs(self.image_processor_tester	,				equal_resolution=lowercase	,				torchify=lowercase							)
				for image in image_inputs:
							self.assertIsInstance(lowercase	,				torch.Tensor							)

				# Test not batched input
				A_     :						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
				A_     :						List[str]     =					image_processing(lowercase	,				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 maths.is_square_free import is_square_free
from maths.prime_factors import prime_factors



def      a      (			lowerCamelCase__   ):
			'''simple docstring'''





			A_     :						List[Any]     =					prime_factors(lowerCamelCase__   )
			if is_square_free(lowerCamelCase__   ):
						return -1 if len(lowerCamelCase__   ) % 2 else 1
			return 0


if __name__ == "__main__":
						import doctest

						doctest.testmod()