code: 
  
  
  
  
  
  '''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
  
  
  if is_torch_available():
  			import torch
  
  if is_vision_available():
  			from PIL import Image
  
  			from transformers import CLIPImageProcessor
  
  
  class 							__snake_case    (				unittest.TestCase       ):
  
  
  
  
  
  	def __init__(		self			,					UpperCamelCase_			,					UpperCamelCase_=7			,					UpperCamelCase_=3			,					UpperCamelCase_=18			,					UpperCamelCase_=30			,					UpperCamelCase_=400			,					UpperCamelCase_=True			,					UpperCamelCase_=None			,					UpperCamelCase_=True			,					UpperCamelCase_=None			,					UpperCamelCase_=True			,					UpperCamelCase_=[0.4_8_1_4_5_4_6_6, 0.4_5_7_8_2_7_5, 0.4_0_8_2_1_0_7_3]			,					UpperCamelCase_=[0.2_6_8_6_2_9_5_4, 0.2_6_1_3_0_2_5_8, 0.2_7_5_7_7_7_1_1]			,					UpperCamelCase_=True			,					)			->		Union[str, Any]:
  		snake_case__  					=      size if size is not None else {'shortest_edge': 20}
  		snake_case__  					=      crop_size if crop_size is not None else {'height': 18, 'width': 18}
  		snake_case__  					=      parent
  		snake_case__  					=      batch_size
  		snake_case__  					=      num_channels
  		snake_case__  					=      image_size
  		snake_case__  					=      min_resolution
  		snake_case__  					=      max_resolution
  		snake_case__  					=      do_resize
  		snake_case__  					=      size
  		snake_case__  					=      do_center_crop
  		snake_case__  					=      crop_size
  		snake_case__  					=      do_normalize
  		snake_case__  					=      image_mean
  		snake_case__  					=      image_std
  		snake_case__  					=      do_convert_rgb
  
  
  
  
  
  	def      _snake_case      (		self		)			->		Tuple:
  		return {
  		    "do_resize": self.do_resize,
  		    "size": self.size,
  		    "do_center_crop": self.do_center_crop,
  		    "crop_size": self.crop_size,
  		    "do_normalize": self.do_normalize,
  		    "image_mean": self.image_mean,
  		    "image_std": self.image_std,
  		    "do_convert_rgb": self.do_convert_rgb,
  		}
  
  
  
  
  
  	def      _snake_case      (		self			,					UpperCamelCase_=False			,					UpperCamelCase_=False			,					UpperCamelCase_=False		)			->		int:
  		assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"
  
  		if equal_resolution:
  			snake_case__  					=      []
  			for i in range(self.batch_size		):
  				image_inputs.append(
  				    np.random.randint(
  				        255			,					size=(self.num_channels, self.max_resolution, self.max_resolution)			,					dtype=np.uinta		)		)
  		else:
  			snake_case__  					=      []
  			for i in range(self.batch_size		):
  				snake_case__					,     snake_case__  					=      np.random.choice(np.arange(self.min_resolution			,					self.max_resolution		)			,					2		)
  				image_inputs.append(np.random.randint(255			,					size=(self.num_channels, width, height)			,					dtype=np.uinta		)		)
  
  		if not numpify and not torchify:
  			# PIL expects the channel dimension as last dimension
  			snake_case__  					=      [Image.fromarray(np.moveaxis(_lowerCAmelCase			,					0			,					-1		)		) for x in image_inputs]
  
  		if torchify:
  			snake_case__  					=      [torch.from_numpy(_lowerCAmelCase		) for x in image_inputs]
  
  		return image_inputs
  
  
  
  
  
  @require_torch
  @require_vision
  class 							__snake_case    (				A__					,					unittest.TestCase       ):
  	__lowerCAmelCase						=     CLIPImageProcessor if is_vision_available() else None
  
  
  
  
  
  	def      _snake_case      (		self		)			->		str:
  		snake_case__  					=      CLIPImageProcessingTester(self		)
  
  
  
  
  
  	@property
  	def      _snake_case      (		self		)			->		Optional[int]:
  		return self.image_processor_tester.prepare_image_processor_dict()
  
  
  
  
  
  	def      _snake_case      (		self		)			->		List[Any]:
  		snake_case__  					=      self.image_processing_class(**self.image_processor_dict		)
  		self.assertTrue(hasattr(_lowerCAmelCase			,					'do_resize'		)		)
  		self.assertTrue(hasattr(_lowerCAmelCase			,					'size'		)		)
  		self.assertTrue(hasattr(_lowerCAmelCase			,					'do_center_crop'		)		)
  		self.assertTrue(hasattr(_lowerCAmelCase			,					'center_crop'		)		)
  		self.assertTrue(hasattr(_lowerCAmelCase			,					'do_normalize'		)		)
  		self.assertTrue(hasattr(_lowerCAmelCase			,					'image_mean'		)		)
  		self.assertTrue(hasattr(_lowerCAmelCase			,					'image_std'		)		)
  		self.assertTrue(hasattr(_lowerCAmelCase			,					'do_convert_rgb'		)		)
  
  
  
  
  
  	def      _snake_case      (		self		)			->		Dict:
  		snake_case__  					=      self.image_processing_class.from_dict(self.image_processor_dict		)
  		self.assertEqual(image_processor.size			,					{'shortest_edge': 20}		)
  		self.assertEqual(image_processor.crop_size			,					{'height': 18, 'width': 18}		)
  
  		snake_case__  					=      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      _snake_case      (		self		)			->		List[Any]:
  		pass
  
  
  
  
  
  	def      _snake_case      (		self		)			->		str:
  		# Initialize image_processing
  		snake_case__  					=      self.image_processing_class(**self.image_processor_dict		)
  		# create random PIL images
  		snake_case__  					=      self.image_processor_tester.prepare_inputs(equal_resolution=_lowerCAmelCase		)
  		for image in image_inputs:
  			self.assertIsInstance(_lowerCAmelCase			,					Image.Image		)
  
  		# Test not batched input
  		snake_case__  					=      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
  		snake_case__  					=      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      _snake_case      (		self		)			->		List[str]:
  		# Initialize image_processing
  		snake_case__  					=      self.image_processing_class(**self.image_processor_dict		)
  		# create random numpy tensors
  		snake_case__  					=      self.image_processor_tester.prepare_inputs(equal_resolution=_lowerCAmelCase			,					numpify=_lowerCAmelCase		)
  		for image in image_inputs:
  			self.assertIsInstance(_lowerCAmelCase			,					np.ndarray		)
  
  		# Test not batched input
  		snake_case__  					=      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
  		snake_case__  					=      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      _snake_case      (		self		)			->		Optional[int]:
  		# Initialize image_processing
  		snake_case__  					=      self.image_processing_class(**self.image_processor_dict		)
  		# create random PyTorch tensors
  		snake_case__  					=      self.image_processor_tester.prepare_inputs(equal_resolution=_lowerCAmelCase			,					torchify=_lowerCAmelCase		)
  		for image in image_inputs:
  			self.assertIsInstance(_lowerCAmelCase			,					torch.Tensor		)
  
  		# Test not batched input
  		snake_case__  					=      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
  		snake_case__  					=      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'],
  		    )			,					)
  
  
  
  
  
  @require_torch
  @require_vision
  class 							__snake_case    (				A__					,					unittest.TestCase       ):
  	__lowerCAmelCase						=     CLIPImageProcessor if is_vision_available() else None
  
  
  
  
  
  	def      _snake_case      (		self		)			->		int:
  		snake_case__  					=      CLIPImageProcessingTester(self			,					num_channels=4		)
  		snake_case__  					=      3
  
  
  
  
  
  	@property
  	def      _snake_case      (		self		)			->		Optional[int]:
  		return self.image_processor_tester.prepare_image_processor_dict()
  
  
  
  
  
  	def      _snake_case      (		self		)			->		Optional[Any]:
  		snake_case__  					=      self.image_processing_class(**self.image_processor_dict		)
  		self.assertTrue(hasattr(_lowerCAmelCase			,					'do_resize'		)		)
  		self.assertTrue(hasattr(_lowerCAmelCase			,					'size'		)		)
  		self.assertTrue(hasattr(_lowerCAmelCase			,					'do_center_crop'		)		)
  		self.assertTrue(hasattr(_lowerCAmelCase			,					'center_crop'		)		)
  		self.assertTrue(hasattr(_lowerCAmelCase			,					'do_normalize'		)		)
  		self.assertTrue(hasattr(_lowerCAmelCase			,					'image_mean'		)		)
  		self.assertTrue(hasattr(_lowerCAmelCase			,					'image_std'		)		)
  		self.assertTrue(hasattr(_lowerCAmelCase			,					'do_convert_rgb'		)		)
  
  
  
  
  
  	def      _snake_case      (		self		)			->		Any:
  		pass
  
  
  
  
  
  	def      _snake_case      (		self		)			->		str:
  		# Initialize image_processing
  		snake_case__  					=      self.image_processing_class(**self.image_processor_dict		)
  		# create random PIL images
  		snake_case__  					=      self.image_processor_tester.prepare_inputs(equal_resolution=_lowerCAmelCase		)
  		for image in image_inputs:
  			self.assertIsInstance(_lowerCAmelCase			,					Image.Image		)
  
  		# Test not batched input
  		snake_case__  					=      image_processing(image_inputs[0]			,					return_tensors='pt'		).pixel_values
  		self.assertEqual(
  		    encoded_images.shape			,					(
  		        1,
  		        self.expected_encoded_image_num_channels,
  		        self.image_processor_tester.crop_size['height'],
  		        self.image_processor_tester.crop_size['width'],
  		    )			,					)
  
  		# Test batched
  		snake_case__  					=      image_processing(_lowerCAmelCase			,					return_tensors='pt'		).pixel_values
  		self.assertEqual(
  		    encoded_images.shape			,					(
  		        self.image_processor_tester.batch_size,
  		        self.expected_encoded_image_num_channels,
  		        self.image_processor_tester.crop_size['height'],
  		        self.image_processor_tester.crop_size['width'],
  		    )			,					)
  
  
  
  
style_context: 
  
  
  
  
  
  '''simple docstring'''
  
  
  
  
  def 	__lowerCamelCase (  UpperCAmelCase_       )      ->int:
  	return 1 if input_a == 0 else 0
  
  
  
  
  def 	__lowerCamelCase (  )      ->None:
  	assert not_gate(0       ) == 1
  	assert not_gate(1       ) == 0
  
  
  if __name__ == "__main__":
  			print(not_gate(0))
  			print(not_gate(1))
  
  
  
  