






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			):

					'''simple docstring'''

					def __init__(  self				:	Optional[Any]		,     __a				:	Any		,     __a				:	Any=7		,     __a				:	Dict=3		,     __a				:	Optional[Any]=30		,     __a				:	int=400		,     __a				:	Tuple=True		,     __a				:	Optional[int]=None		,     __a				:	str=0.9		,     __a				:	Optional[Any]=None		,     __a				:	Tuple=True		,     __a				:	Union[str, Any]=[0.5, 0.5, 0.5]		,     __a				:	List[str]=[0.5, 0.5, 0.5]		,     )			->  Optional[int]:


												"""simple docstring"""

												__lowercase      :							Optional[int]				=     size if size is not None else {"""shortest_edge""": 30}
												__lowercase      :							int				=     crop_size if crop_size is not None else {"""height""": 30, """width""": 30}
												__lowercase      :							str				=     parent
												__lowercase      :							Dict				=     batch_size
												__lowercase      :							Tuple				=     num_channels
												__lowercase      :							Optional[Any]				=     min_resolution
												__lowercase      :							Tuple				=     max_resolution
												__lowercase      :							List[Any]				=     do_resize_and_center_crop
												__lowercase      :							Dict				=     size
												__lowercase      :							Optional[Any]				=     crop_pct
												__lowercase      :							Dict				=     crop_size
												__lowercase      :							Optional[Any]				=     do_normalize
												__lowercase      :							List[str]				=     image_mean
												__lowercase      :							Optional[int]				=     image_std



					def       lowerCAmelCase				(  self				:	Dict							)			->  Tuple:


												"""simple docstring"""

												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     ( __a      ,       unittest.TestCase			):

					'''simple docstring'''

					_A						:			Optional[int]									=      PoolFormerImageProcessor if is_vision_available() else None



					def       lowerCAmelCase				(  self				:	Any							)			->  int:


												"""simple docstring"""

												__lowercase      :							Optional[Any]				=     PoolFormerImageProcessingTester(self							)



					@property
					def       lowerCAmelCase				(  self				:	int							)			->  List[Any]:


												"""simple docstring"""

												return self.image_processor_tester.prepare_image_processor_dict()



					def       lowerCAmelCase				(  self				:	List[str]							)			->  str:


												"""simple docstring"""

												__lowercase      :							List[Any]				=     self.image_processing_class(**self.image_processor_dict							)
												self.assertTrue(hasattr(__a		,     """do_resize_and_center_crop"""							)							)
												self.assertTrue(hasattr(__a		,     """size"""							)							)
												self.assertTrue(hasattr(__a		,     """crop_pct"""							)							)
												self.assertTrue(hasattr(__a		,     """do_normalize"""							)							)
												self.assertTrue(hasattr(__a		,     """image_mean"""							)							)
												self.assertTrue(hasattr(__a		,     """image_std"""							)							)



					def       lowerCAmelCase				(  self				:	str							)			->  Optional[Any]:


												"""simple docstring"""

												__lowercase      :							Union[str, 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}							)

												__lowercase      :							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       lowerCAmelCase				(  self				:	Dict							)			->  int:


												"""simple docstring"""

												pass



					def       lowerCAmelCase				(  self				:	Optional[int]							)			->  Optional[Any]:


												"""simple docstring"""

												__lowercase      :							Union[str, Any]				=     self.image_processing_class(**self.image_processor_dict							)
												# create random PIL images
												__lowercase      :							int				=     prepare_image_inputs(self.image_processor_tester		,     equal_resolution=__a							)
												for image in image_inputs:
																			self.assertIsInstance(__a		,     Image.Image							)

												# Test not batched input
												__lowercase      :							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
												__lowercase      :							List[str]				=     image_processing(__a		,     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       lowerCAmelCase				(  self				:	Any							)			->  int:


												"""simple docstring"""

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

												# Test not batched input
												__lowercase      :							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
												__lowercase      :							Union[str, Any]				=     image_processing(__a		,     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       lowerCAmelCase				(  self				:	List[Any]							)			->  Any:


												"""simple docstring"""

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

												# Test not batched input
												__lowercase      :							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
												__lowercase      :							List[str]				=     image_processing(__a		,     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       snake_case_		(     lowerCAmelCase_       :						int       ,       lowerCAmelCase_       :						int      ):
							return int((input_a, input_a).count(0      ) == 0      )
def       snake_case_		(     ):
							assert and_gate(0       ,       0      ) == 0
							assert and_gate(0       ,       1      ) == 0
							assert and_gate(1       ,       0      ) == 0
							assert and_gate(1       ,       1      ) == 1


if __name__ == "__main__":
	test_and_gate()
	print(and_gate(1, 0))
	print(and_gate(0, 0))
	print(and_gate(0, 1))
	print(and_gate(1, 1))