


"""simple docstring"""






UpperCamelCase__				:Dict			   =	65_521





def 				A_       ( snake_case__		)					->  int:
			_UpperCamelCase					:int					     =	1
			_UpperCamelCase					:List[Any]					     =	0
			for plain_chr in plain_text:
						_UpperCamelCase					:str					     =	(a + ord(snake_case__		)) % MOD_ADLER
						_UpperCamelCase					:List[Any]					     =	(b + a) % MOD_ADLER
			return (b << 16) | a





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






class      A(  unittest.TestCase		):

		"""simple docstring"""





		def __init__( self					,				SCREAMING_SNAKE_CASE__					,				SCREAMING_SNAKE_CASE__=7					,				SCREAMING_SNAKE_CASE__=3					,				SCREAMING_SNAKE_CASE__=18					,				SCREAMING_SNAKE_CASE__=30					,				SCREAMING_SNAKE_CASE__=4_00					,				SCREAMING_SNAKE_CASE__=True					,				SCREAMING_SNAKE_CASE__=None					,				SCREAMING_SNAKE_CASE__=True					,				SCREAMING_SNAKE_CASE__=None					,				)      ->	Dict:

					"""simple docstring"""



					_UpperCamelCase					:Dict					     =	size if size is not None else {'''shortest_edge''': 20}
					_UpperCamelCase					:Union[str, Any]					     =	crop_size if crop_size is not None else {'''height''': 18, '''width''': 18}
					_UpperCamelCase					:str					     =	parent
					_UpperCamelCase					:str					     =	batch_size
					_UpperCamelCase					:str					     =	num_channels
					_UpperCamelCase					:Optional[Any]					     =	image_size
					_UpperCamelCase					:List[str]					     =	min_resolution
					_UpperCamelCase					:Tuple					     =	max_resolution
					_UpperCamelCase					:List[Any]					     =	do_resize
					_UpperCamelCase					:Tuple					     =	size
					_UpperCamelCase					:int					     =	do_center_crop
					_UpperCamelCase					:Optional[int]					     =	crop_size





		def   _UpperCamelCase( self   )      ->	int:

					"""simple docstring"""



					return {
					    "do_resize": self.do_resize,
					    "size": self.size,
					    "do_center_crop": self.do_center_crop,
					    "crop_size": self.crop_size,
					}






@require_torch
@require_vision
class      A(  lowerCamelCase__				,							unittest.TestCase		):

		"""simple docstring"""





		A    =							MobileNetVaImageProcessor if is_vision_available() else None
		def   _UpperCamelCase( self   )      ->	List[Any]:

					"""simple docstring"""



					_UpperCamelCase					:int					     =	MobileNetVaImageProcessingTester(self   )
		@property
		def   _UpperCamelCase( self   )      ->	List[str]:

					"""simple docstring"""



					return self.image_processor_tester.prepare_image_processor_dict()
		def   _UpperCamelCase( self   )      ->	List[Any]:

					"""simple docstring"""



					_UpperCamelCase					:Union[str, Any]					     =	self.image_processing_class(**self.image_processor_dict   )
					self.assertTrue(hasattr(SCREAMING_SNAKE_CASE__					,				'''do_resize'''   )   )
					self.assertTrue(hasattr(SCREAMING_SNAKE_CASE__					,				'''size'''   )   )
					self.assertTrue(hasattr(SCREAMING_SNAKE_CASE__					,				'''do_center_crop'''   )   )
					self.assertTrue(hasattr(SCREAMING_SNAKE_CASE__					,				'''crop_size'''   )   )
		def   _UpperCamelCase( self   )      ->	Dict:

					"""simple docstring"""



					_UpperCamelCase					:List[str]					     =	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}   )

					_UpperCamelCase					:List[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   _UpperCamelCase( self   )      ->	List[Any]:

					"""simple docstring"""



					pass
		def   _UpperCamelCase( self   )      ->	Dict:

					"""simple docstring"""



					_UpperCamelCase					:Any					     =	self.image_processing_class(**self.image_processor_dict   )
					# create random PIL images
					_UpperCamelCase					:Union[str, Any]					     =	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
					_UpperCamelCase					: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
					_UpperCamelCase					: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.crop_size['''height'''],
					        self.image_processor_tester.crop_size['''width'''],
					    )					,				)
		def   _UpperCamelCase( self   )      ->	Tuple:

					"""simple docstring"""



					_UpperCamelCase					:int					     =	self.image_processing_class(**self.image_processor_dict   )
					# create random numpy tensors
					_UpperCamelCase					:Any					     =	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
					_UpperCamelCase					: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
					_UpperCamelCase					: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.crop_size['''height'''],
					        self.image_processor_tester.crop_size['''width'''],
					    )					,				)





		def   _UpperCamelCase( self   )      ->	Any:

					"""simple docstring"""



					_UpperCamelCase					:List[Any]					     =	self.image_processing_class(**self.image_processor_dict   )
					# create random PyTorch tensors
					_UpperCamelCase					:Union[str, 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
					_UpperCamelCase					: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.crop_size['''height'''],
					        self.image_processor_tester.crop_size['''width'''],
					    )					,				)

					# Test batched
					_UpperCamelCase					:Optional[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.crop_size['''height'''],
					        self.image_processor_tester.crop_size['''width'''],
					    )					,				)

