

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_video_inputs


if is_torch_available():
	import torch

if is_vision_available():
	from PIL import Image

	from transformers import VideoMAEImageProcessor



class    A__(unittest.TestCase    ):
						"""simple docstring"""






						def __init__(  self       ,     _lowercase       ,     _lowercase=7       ,     _lowercase=3       ,     _lowercase=10       ,     _lowercase=18       ,     _lowercase=30       ,     _lowercase=400       ,     _lowercase=True       ,     _lowercase=None       ,     _lowercase=True       ,     _lowercase=[0.5, 0.5, 0.5]       ,     _lowercase=[0.5, 0.5, 0.5]       ,     _lowercase=None       ,     )      ->				str:
									a_		:		List[Any]				    =				size if size is not None else {"""shortest_edge""": 18}
									a_		:		List[str]				    =				crop_size if crop_size is not None else {"""height""": 18, """width""": 18}

									a_		:		Dict				    =				parent
									a_		:		Optional[int]				    =				batch_size
									a_		:		int				    =				num_channels
									a_		:		List[Any]				    =				num_frames
									a_		:		Union[str, Any]				    =				image_size
									a_		:		List[Any]				    =				min_resolution
									a_		:		Any				    =				max_resolution
									a_		:		Dict				    =				do_resize
									a_		:		Optional[int]				    =				size
									a_		:		Any				    =				do_normalize
									a_		:		int				    =				image_mean
									a_		:		Any				    =				image_std
									a_		:		str				    =				crop_size





						def 	UpperCamelCase__			(  self  )      ->				Optional[int]:
									return {
									    "image_mean": self.image_mean,
									    "image_std": self.image_std,
									    "do_normalize": self.do_normalize,
									    "do_resize": self.do_resize,
									    "size": self.size,
									    "crop_size": self.crop_size,
									}







@require_torch
@require_vision
class    A__(a_,       unittest.TestCase    ):
						"""simple docstring"""






						_A  :							Union[str, Any]   			=	VideoMAEImageProcessor if is_vision_available() else None





						def 	UpperCamelCase__			(  self  )      ->				List[Any]:
									a_		:		str				    =				VideoMAEImageProcessingTester(self  )





						@property
						def 	UpperCamelCase__			(  self  )      ->				Optional[int]:
									return self.image_processor_tester.prepare_image_processor_dict()





						def 	UpperCamelCase__			(  self  )      ->				str:
									a_		:		Optional[Any]				    =				self.image_processing_class(**self.image_processor_dict  )
									self.assertTrue(hasattr(_lowercase       ,     """image_mean"""  )  )
									self.assertTrue(hasattr(_lowercase       ,     """image_std"""  )  )
									self.assertTrue(hasattr(_lowercase       ,     """do_normalize"""  )  )
									self.assertTrue(hasattr(_lowercase       ,     """do_resize"""  )  )
									self.assertTrue(hasattr(_lowercase       ,     """do_center_crop"""  )  )
									self.assertTrue(hasattr(_lowercase       ,     """size"""  )  )





						def 	UpperCamelCase__			(  self  )      ->				Optional[int]:
									a_		:		List[str]				    =				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[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 	UpperCamelCase__			(  self  )      ->				List[Any]:
									pass





						def 	UpperCamelCase__			(  self  )      ->				Union[str, Any]:
									# Initialize image_processing
									a_		:		Dict				    =				self.image_processing_class(**self.image_processor_dict  )
									# create random PIL videos
									a_		:		int				    =				prepare_video_inputs(self.image_processor_tester       ,     equal_resolution=_lowercase  )
									for video in video_inputs:
												self.assertIsInstance(_lowercase       ,     _lowercase  )
												self.assertIsInstance(video[0]       ,     Image.Image  )

									# Test not batched input
									a_		:		int				    =				image_processing(video_inputs[0]       ,     return_tensors="""pt"""  ).pixel_values
									self.assertEqual(
									    encoded_videos.shape       ,     (
									        1,
									        self.image_processor_tester.num_frames,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.crop_size["""height"""],
									        self.image_processor_tester.crop_size["""width"""],
									    )       ,     )

									# Test batched
									a_		:		Any				    =				image_processing(_lowercase       ,     return_tensors="""pt"""  ).pixel_values
									self.assertEqual(
									    encoded_videos.shape       ,     (
									        self.image_processor_tester.batch_size,
									        self.image_processor_tester.num_frames,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.crop_size["""height"""],
									        self.image_processor_tester.crop_size["""width"""],
									    )       ,     )





						def 	UpperCamelCase__			(  self  )      ->				Tuple:
									# Initialize image_processing
									a_		:		Tuple				    =				self.image_processing_class(**self.image_processor_dict  )
									# create random numpy tensors
									a_		:		Optional[int]				    =				prepare_video_inputs(self.image_processor_tester       ,     equal_resolution=_lowercase       ,     numpify=_lowercase  )
									for video in video_inputs:
												self.assertIsInstance(_lowercase       ,     _lowercase  )
												self.assertIsInstance(video[0]       ,     np.ndarray  )

									# Test not batched input
									a_		:		Optional[Any]				    =				image_processing(video_inputs[0]       ,     return_tensors="""pt"""  ).pixel_values
									self.assertEqual(
									    encoded_videos.shape       ,     (
									        1,
									        self.image_processor_tester.num_frames,
									        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(_lowercase       ,     return_tensors="""pt"""  ).pixel_values
									self.assertEqual(
									    encoded_videos.shape       ,     (
									        self.image_processor_tester.batch_size,
									        self.image_processor_tester.num_frames,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.crop_size["""height"""],
									        self.image_processor_tester.crop_size["""width"""],
									    )       ,     )





						def 	UpperCamelCase__			(  self  )      ->				Optional[int]:
									# Initialize image_processing
									a_		:		List[Any]				    =				self.image_processing_class(**self.image_processor_dict  )
									# create random PyTorch tensors
									a_		:		List[str]				    =				prepare_video_inputs(self.image_processor_tester       ,     equal_resolution=_lowercase       ,     torchify=_lowercase  )
									for video in video_inputs:
												self.assertIsInstance(_lowercase       ,     _lowercase  )
												self.assertIsInstance(video[0]       ,     torch.Tensor  )

									# Test not batched input
									a_		:		int				    =				image_processing(video_inputs[0]       ,     return_tensors="""pt"""  ).pixel_values
									self.assertEqual(
									    encoded_videos.shape       ,     (
									        1,
									        self.image_processor_tester.num_frames,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.crop_size["""height"""],
									        self.image_processor_tester.crop_size["""width"""],
									    )       ,     )

									# Test batched
									a_		:		Tuple				    =				image_processing(_lowercase       ,     return_tensors="""pt"""  ).pixel_values
									self.assertEqual(
									    encoded_videos.shape       ,     (
									        self.image_processor_tester.batch_size,
									        self.image_processor_tester.num_frames,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.crop_size["""height"""],
									        self.image_processor_tester.crop_size["""width"""],
									    )       ,     )





def 			_UpperCAmelCase							(		a__):

			'''simple docstring'''



			return 1 if input_a == 0 else 0


def 			_UpperCAmelCase							(		):

			'''simple docstring'''



			assert not_gate(0) == 1
			assert not_gate(1) == 0


if __name__ == "__main__":
	print(not_gate(0))
	print(not_gate(1))


