




"""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 ViTImageProcessor



class   a__					(						unittest.TestCase ):


			def __init__(   self   :     Optional[Any]   ,	UpperCamelCase_   :     int   ,	UpperCamelCase_   :     Any=13   ,	UpperCamelCase_   :     Optional[int]=3   ,	UpperCamelCase_   :     int=224   ,	UpperCamelCase_   :     int=30   ,	UpperCamelCase_   :     str=400   ,	UpperCamelCase_   :     List[Any]=True   ,	UpperCamelCase_   :     Optional[Any]=None   ,	UpperCamelCase_   :     Optional[int]=True   ,	UpperCamelCase_   :     Optional[int]=[0.5, 0.5, 0.5]   ,	UpperCamelCase_   :     Optional[Any]=[0.5, 0.5, 0.5]   ,	):


						"""simple docstring"""




						__UpperCAmelCase						:			Tuple												=       size if size is not None else {"height": 18, "width": 18}
						__UpperCAmelCase						:			List[Any]												=       parent
						__UpperCAmelCase						:			Tuple												=       batch_size
						__UpperCAmelCase						:			Tuple												=       num_channels
						__UpperCAmelCase						:			List[Any]												=       image_size
						__UpperCAmelCase						:			str												=       min_resolution
						__UpperCAmelCase						:			Tuple												=       max_resolution
						__UpperCAmelCase						:			Optional[Any]												=       do_resize
						__UpperCAmelCase						:			Any												=       size
						__UpperCAmelCase						:			Any												=       do_normalize
						__UpperCAmelCase						:			Any												=       image_mean
						__UpperCAmelCase						:			Optional[Any]												=       image_std


			def    a_  (   self   :     str):


						"""simple docstring"""




						return {
						    "image_mean": self.image_mean,
						    "image_std": self.image_std,
						    "do_normalize": self.do_normalize,
						    "do_resize": self.do_resize,
						    "size": self.size,
						}






@require_torch
@require_vision
class   a__					(						__magic_name__				,     unittest.TestCase ):
			lowercase_		=						ViTImageProcessor if is_vision_available() else None


			def    a_  (   self   :     Any):


						"""simple docstring"""




						__UpperCAmelCase						:			Optional[Any]												=       EfficientFormerImageProcessorTester(self)


			@property
			def    a_  (   self   :     Union[str, Any]):


						"""simple docstring"""




						return self.image_proc_tester.prepare_image_processor_dict()


			def    a_  (   self   :     Tuple):


						"""simple docstring"""




						__UpperCAmelCase						:			Tuple												=       self.image_processing_class(**self.image_processor_dict)
						self.assertTrue(hasattr(UpperCamelCase_   ,	"image_mean"))
						self.assertTrue(hasattr(UpperCamelCase_   ,	"image_std"))
						self.assertTrue(hasattr(UpperCamelCase_   ,	"do_normalize"))
						self.assertTrue(hasattr(UpperCamelCase_   ,	"do_resize"))
						self.assertTrue(hasattr(UpperCamelCase_   ,	"size"))


			def    a_  (   self   :     Dict):


						"""simple docstring"""




						pass


			def    a_  (   self   :     Tuple):


						"""simple docstring"""




						__UpperCAmelCase						:			Optional[Any]												=       self.image_processing_class(**self.image_processor_dict)
						# create random PIL images
						__UpperCAmelCase						:			str												=       prepare_image_inputs(self.image_proc_tester   ,	equal_resolution=UpperCamelCase_)
						for image in image_inputs:
									self.assertIsInstance(UpperCamelCase_   ,	Image.Image)

						# Test not batched input
						__UpperCAmelCase						:			Optional[int]												=       image_processor(image_inputs[0]   ,	return_tensors="pt").pixel_values
						self.assertEqual(
						    encoded_images.shape   ,	(
						        1,
						        self.image_proc_tester.num_channels,
						        self.image_proc_tester.size["height"],
						        self.image_proc_tester.size["width"],
						    )   ,	)

						# Test batched
						__UpperCAmelCase						:			Optional[int]												=       image_processor(UpperCamelCase_   ,	return_tensors="pt").pixel_values
						self.assertEqual(
						    encoded_images.shape   ,	(
						        self.image_proc_tester.batch_size,
						        self.image_proc_tester.num_channels,
						        self.image_proc_tester.size["height"],
						        self.image_proc_tester.size["width"],
						    )   ,	)


			def    a_  (   self   :     Tuple):


						"""simple docstring"""




						__UpperCAmelCase						:			int												=       self.image_processing_class(**self.image_processor_dict)
						# create random numpy tensors
						__UpperCAmelCase						:			Union[str, Any]												=       prepare_image_inputs(self.image_proc_tester   ,	equal_resolution=UpperCamelCase_   ,	numpify=UpperCamelCase_)
						for image in image_inputs:
									self.assertIsInstance(UpperCamelCase_   ,	np.ndarray)

						# Test not batched input
						__UpperCAmelCase						:			Tuple												=       image_processor(image_inputs[0]   ,	return_tensors="pt").pixel_values
						self.assertEqual(
						    encoded_images.shape   ,	(
						        1,
						        self.image_proc_tester.num_channels,
						        self.image_proc_tester.size["height"],
						        self.image_proc_tester.size["width"],
						    )   ,	)

						# Test batched
						__UpperCAmelCase						:			Any												=       image_processor(UpperCamelCase_   ,	return_tensors="pt").pixel_values
						self.assertEqual(
						    encoded_images.shape   ,	(
						        self.image_proc_tester.batch_size,
						        self.image_proc_tester.num_channels,
						        self.image_proc_tester.size["height"],
						        self.image_proc_tester.size["width"],
						    )   ,	)


			def    a_  (   self   :     Any):


						"""simple docstring"""




						__UpperCAmelCase						:			Dict												=       self.image_processing_class(**self.image_processor_dict)
						# create random PyTorch tensors
						__UpperCAmelCase						:			Any												=       prepare_image_inputs(self.image_proc_tester   ,	equal_resolution=UpperCamelCase_   ,	torchify=UpperCamelCase_)
						for image in image_inputs:
									self.assertIsInstance(UpperCamelCase_   ,	torch.Tensor)

						# Test not batched input
						__UpperCAmelCase						:			Optional[Any]												=       image_processor(image_inputs[0]   ,	return_tensors="pt").pixel_values
						self.assertEqual(
						    encoded_images.shape   ,	(
						        1,
						        self.image_proc_tester.num_channels,
						        self.image_proc_tester.size["height"],
						        self.image_proc_tester.size["width"],
						    )   ,	)

						# Test batched
						__UpperCAmelCase						:			Optional[int]												=       image_processor(UpperCamelCase_   ,	return_tensors="pt").pixel_values
						self.assertEqual(
						    encoded_images.shape   ,	(
						        self.image_proc_tester.batch_size,
						        self.image_proc_tester.num_channels,
						        self.image_proc_tester.size["height"],
						        self.image_proc_tester.size["width"],
						    )   ,	)




'''simple docstring'''





from ..utils import DummyObject, requires_backends






class 							UpperCAmelCase_							(    metaclass=A				):

 '''simple docstring'''
 lowercase_					:    Optional[int]				=							["torch", "transformers", "onnx"]







 def __init__(					self		:  Tuple			,				*snake_case__		:  str			,				**snake_case__		:  List[str] ):



   '''simple docstring'''




   requires_backends(self			,				["torch", "transformers", "onnx"] )







 @classmethod
 def 							UpperCamelCase  (					cls		:  Optional[int]			,				*snake_case__		:  Any			,				**snake_case__		:  List[Any] ):



   '''simple docstring'''




   requires_backends(cls			,				["torch", "transformers", "onnx"] )







 @classmethod
 def 							UpperCamelCase  (					cls		:  List[str]			,				*snake_case__		:  Any			,				**snake_case__		:  Tuple ):



   '''simple docstring'''




   requires_backends(cls			,				["torch", "transformers", "onnx"] )






class 							UpperCAmelCase_							(    metaclass=A				):

 '''simple docstring'''
 lowercase_					:    Tuple				=							["torch", "transformers", "onnx"]







 def __init__(					self		:  List[str]			,				*snake_case__		:  List[Any]			,				**snake_case__		:  Any ):



   '''simple docstring'''




   requires_backends(self			,				["torch", "transformers", "onnx"] )







 @classmethod
 def 							UpperCamelCase  (					cls		:  Dict			,				*snake_case__		:  Any			,				**snake_case__		:  Optional[int] ):



   '''simple docstring'''




   requires_backends(cls			,				["torch", "transformers", "onnx"] )







 @classmethod
 def 							UpperCamelCase  (					cls		:  int			,				*snake_case__		:  Dict			,				**snake_case__		:  List[Any] ):



   '''simple docstring'''




   requires_backends(cls			,				["torch", "transformers", "onnx"] )






class 							UpperCAmelCase_							(    metaclass=A				):

 '''simple docstring'''
 lowercase_					:    Optional[int]				=							["torch", "transformers", "onnx"]







 def __init__(					self		:  str			,				*snake_case__		:  Optional[int]			,				**snake_case__		:  str ):



   '''simple docstring'''




   requires_backends(self			,				["torch", "transformers", "onnx"] )







 @classmethod
 def 							UpperCamelCase  (					cls		:  Any			,				*snake_case__		:  List[str]			,				**snake_case__		:  Dict ):



   '''simple docstring'''




   requires_backends(cls			,				["torch", "transformers", "onnx"] )







 @classmethod
 def 							UpperCamelCase  (					cls		:  str			,				*snake_case__		:  Dict			,				**snake_case__		:  Dict ):



   '''simple docstring'''




   requires_backends(cls			,				["torch", "transformers", "onnx"] )






class 							UpperCAmelCase_							(    metaclass=A				):

 '''simple docstring'''
 lowercase_					:    int				=							["torch", "transformers", "onnx"]







 def __init__(					self		:  Any			,				*snake_case__		:  List[str]			,				**snake_case__		:  str ):



   '''simple docstring'''




   requires_backends(self			,				["torch", "transformers", "onnx"] )







 @classmethod
 def 							UpperCamelCase  (					cls		:  List[str]			,				*snake_case__		:  List[str]			,				**snake_case__		:  Optional[Any] ):



   '''simple docstring'''




   requires_backends(cls			,				["torch", "transformers", "onnx"] )







 @classmethod
 def 							UpperCamelCase  (					cls		:  Optional[int]			,				*snake_case__		:  List[Any]			,				**snake_case__		:  int ):



   '''simple docstring'''




   requires_backends(cls			,				["torch", "transformers", "onnx"] )






class 							UpperCAmelCase_							(    metaclass=A				):

 '''simple docstring'''
 lowercase_					:    Dict				=							["torch", "transformers", "onnx"]







 def __init__(					self		:  Any			,				*snake_case__		:  Optional[int]			,				**snake_case__		:  Any ):



   '''simple docstring'''




   requires_backends(self			,				["torch", "transformers", "onnx"] )







 @classmethod
 def 							UpperCamelCase  (					cls		:  Union[str, Any]			,				*snake_case__		:  str			,				**snake_case__		:  Optional[Any] ):



   '''simple docstring'''




   requires_backends(cls			,				["torch", "transformers", "onnx"] )







 @classmethod
 def 							UpperCamelCase  (					cls		:  int			,				*snake_case__		:  int			,				**snake_case__		:  Tuple ):



   '''simple docstring'''




   requires_backends(cls			,				["torch", "transformers", "onnx"] )






class 							UpperCAmelCase_							(    metaclass=A				):

 '''simple docstring'''
 lowercase_					:    Dict				=							["torch", "transformers", "onnx"]







 def __init__(					self		:  List[str]			,				*snake_case__		:  Tuple			,				**snake_case__		:  int ):



   '''simple docstring'''




   requires_backends(self			,				["torch", "transformers", "onnx"] )







 @classmethod
 def 							UpperCamelCase  (					cls		:  Optional[int]			,				*snake_case__		:  Tuple			,				**snake_case__		:  Dict ):



   '''simple docstring'''




   requires_backends(cls			,				["torch", "transformers", "onnx"] )







 @classmethod
 def 							UpperCamelCase  (					cls		:  List[str]			,				*snake_case__		:  Dict			,				**snake_case__		:  List[Any] ):



   '''simple docstring'''




   requires_backends(cls			,				["torch", "transformers", "onnx"] )



