"""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 EfficientNetImageProcessor
class   UpperCAmelCase__				(    unittest.TestCase			):


	"""simple docstring"""







	def __init__(			self       ,     _SCREAMING_SNAKE_CASE       ,     _SCREAMING_SNAKE_CASE=1_3       ,     _SCREAMING_SNAKE_CASE=3       ,     _SCREAMING_SNAKE_CASE=1_8       ,     _SCREAMING_SNAKE_CASE=3_0       ,     _SCREAMING_SNAKE_CASE=4_0_0       ,     _SCREAMING_SNAKE_CASE=True       ,     _SCREAMING_SNAKE_CASE=None       ,     _SCREAMING_SNAKE_CASE=True       ,     _SCREAMING_SNAKE_CASE=[0.5, 0.5, 0.5]       ,     _SCREAMING_SNAKE_CASE=[0.5, 0.5, 0.5]       ,     )    ->	Tuple:
							a_							:			str     		=					size if size is not None else {"height": 1_8, "width": 1_8}
							a_							:			Optional[int]     		=					parent
							a_							:			List[Any]     		=					batch_size
							a_							:			Dict     		=					num_channels
							a_							:			Union[str, Any]     		=					image_size
							a_							:			List[str]     		=					min_resolution
							a_							:			Dict     		=					max_resolution
							a_							:			str     		=					do_resize
							a_							:			str     		=					size
							a_							:			Optional[int]     		=					do_normalize
							a_							:			Union[str, Any]     		=					image_mean
							a_							:			Any     		=					image_std







	def       A    (			self )    ->	Optional[Any]:
							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   UpperCAmelCase__				(    __lowerCamelCase,      unittest.TestCase			):


	"""simple docstring"""
	lowerCAmelCase__    :					int						      =							EfficientNetImageProcessor if is_vision_available() else None







	def       A    (			self )    ->	Optional[Any]:
							a_							:			str     		=					EfficientNetImageProcessorTester(self )







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







	def       A    (			self )    ->	str:
							a_							:			Union[str, Any]     		=					self.image_processing_class(**self.image_processor_dict )
							self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE       ,     "image_mean" ) )
							self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE       ,     "image_std" ) )
							self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE       ,     "do_normalize" ) )
							self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE       ,     "do_resize" ) )
							self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE       ,     "size" ) )







	def       A    (			self )    ->	Optional[int]:
							a_							:			int     		=					self.image_processing_class.from_dict(self.image_processor_dict )
							self.assertEqual(image_processor.size       ,     {"height": 1_8, "width": 1_8} )

							a_							:			Optional[Any]     		=					self.image_processing_class.from_dict(self.image_processor_dict       ,     size=4_2 )
							self.assertEqual(image_processor.size       ,     {"height": 4_2, "width": 4_2} )







	def       A    (			self )    ->	Tuple:
							# Initialize image_processing
							a_							:			List[str]     		=					self.image_processing_class(**self.image_processor_dict )
							# create random PIL images
							a_							:			int     		=					prepare_image_inputs(self.image_processor_tester       ,     equal_resolution=_SCREAMING_SNAKE_CASE )
							for image in image_inputs:
													self.assertIsInstance(_SCREAMING_SNAKE_CASE       ,     Image.Image )

							# Test not batched input
							a_							:			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.size["height"],
							        self.image_processor_tester.size["width"],
							    )       ,     )

							# Test batched
							a_							:			List[str]     		=					image_processing(_SCREAMING_SNAKE_CASE       ,     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.size["height"],
							        self.image_processor_tester.size["width"],
							    )       ,     )







	def       A    (			self )    ->	Optional[Any]:
							# Initialize image_processing
							a_							:			str     		=					self.image_processing_class(**self.image_processor_dict )
							# create random numpy tensors
							a_							:			str     		=					prepare_image_inputs(self.image_processor_tester       ,     equal_resolution=_SCREAMING_SNAKE_CASE       ,     numpify=_SCREAMING_SNAKE_CASE )
							for image in image_inputs:
													self.assertIsInstance(_SCREAMING_SNAKE_CASE       ,     np.ndarray )

							# Test not batched input
							a_							:			List[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.size["height"],
							        self.image_processor_tester.size["width"],
							    )       ,     )

							# Test batched
							a_							:			int     		=					image_processing(_SCREAMING_SNAKE_CASE       ,     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.size["height"],
							        self.image_processor_tester.size["width"],
							    )       ,     )







	def       A    (			self )    ->	Optional[int]:
							# Initialize image_processing
							a_							:			Union[str, 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=_SCREAMING_SNAKE_CASE       ,     torchify=_SCREAMING_SNAKE_CASE )
							for image in image_inputs:
													self.assertIsInstance(_SCREAMING_SNAKE_CASE       ,     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.size["height"],
							        self.image_processor_tester.size["width"],
							    )       ,     )

							# Test batched
							a_							:			List[Any]     		=					image_processing(_SCREAMING_SNAKE_CASE       ,     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.size["height"],
							        self.image_processor_tester.size["width"],
							    )       ,     )





"""simple docstring"""






def  lowerCAmelCase_      (_SCREAMING_SNAKE_CASE	:str  )				-> int:
						a_							:			Optional[int]     		=					0
						for letter in data:
												a_							:			Union[str, Any]     		=					(hash_ << 4) + ord(_SCREAMING_SNAKE_CASE  )
												a_							:			Optional[int]     		=					hash_ & 0xf000_0000
												if x != 0:
																		hash_ ^= x >> 24
												hash_ &= ~x
						return hash_


if __name__ == "__main__":
				import doctest

				doctest.testmod()




