






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 DeiTImageProcessor




class 						UpperCAmelCase_  (		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=400						, _SCREAMING_SNAKE_CASE=True						, _SCREAMING_SNAKE_CASE=None						, _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]						, )       -> Optional[int]:
								snake_case_ :							int         =				size if size is not None else {"height": 20, "width": 20}
								snake_case_ :							Tuple         =				crop_size if crop_size is not None else {"height": 18, "width": 18}

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






						def 					_lowerCAmelCase				(		self )       -> List[Any]:
								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,
								}




@require_torch
@require_vision
class 						UpperCAmelCase_  (		SCREAMING_SNAKE_CASE__    ,     unittest.TestCase    ):


						'''simple docstring'''




						A   :      Optional[int]						 =    DeiTImageProcessor if is_vision_available() else None
						A   :      List[str]						 =    True






						def 					_lowerCAmelCase				(		self )       -> List[str]:
								snake_case_ :							Tuple         =				DeiTImageProcessingTester(self )






						@property
						def 					_lowerCAmelCase				(		self )       -> Dict:
								return self.image_processor_tester.prepare_image_processor_dict()






						def 					_lowerCAmelCase				(		self )       -> int:
								snake_case_ :							Dict         =				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						, "center_crop" ) )
								self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE						, "do_normalize" ) )
								self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE						, "image_mean" ) )
								self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE						, "image_std" ) )






						def 					_lowerCAmelCase				(		self )       -> str:
								snake_case_ :							Optional[Any]         =				self.image_processing_class.from_dict(self.image_processor_dict )
								self.assertEqual(image_processor.size						, {"height": 20, "width": 20} )
								self.assertEqual(image_processor.crop_size						, {"height": 18, "width": 18} )

								snake_case_ :							List[Any]         =				self.image_processing_class.from_dict(self.image_processor_dict						, size=42						, crop_size=84 )
								self.assertEqual(image_processor.size						, {"height": 42, "width": 42} )
								self.assertEqual(image_processor.crop_size						, {"height": 84, "width": 84} )






						def 					_lowerCAmelCase				(		self )       -> Optional[int]:
								pass






						def 					_lowerCAmelCase				(		self )       -> Union[str, Any]:
								# Initialize image_processing
								snake_case_ :							Optional[Any]         =				self.image_processing_class(**self.image_processor_dict )
								# create random PIL images
								snake_case_ :							List[str]         =				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
								snake_case_ :							int         =				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_ :							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 					_lowerCAmelCase				(		self )       -> Tuple:
								# Initialize image_processing
								snake_case_ :							Optional[int]         =				self.image_processing_class(**self.image_processor_dict )
								# create random numpy tensors
								snake_case_ :							Union[str, 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
								snake_case_ :							Tuple         =				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_ :							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.crop_size["height"],
								        self.image_processor_tester.crop_size["width"],
								    )						, )






						def 					_lowerCAmelCase				(		self )       -> Tuple:
								# Initialize image_processing
								snake_case_ :							Optional[Any]         =				self.image_processing_class(**self.image_processor_dict )
								# create random PyTorch tensors
								snake_case_ :							Tuple         =				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
								snake_case_ :							Dict         =				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_ :							Dict         =				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    lowerCAmelCase__		(			_a				:	str     ,					_a				:	int = 13			):
		snake_case_ :							List[Any]         =				""
		for c in s:
				if "A" <= c <= "Z":
						out += chr(ord("A"			) + (ord(_a			) - ord("A"			) + n) % 26			)
				elif "a" <= c <= "z":
						out += chr(ord("a"			) + (ord(_a			) - ord("a"			) + n) % 26			)
				else:
						out += c
		return out

def    lowerCAmelCase__		(			):
		snake_case_ :							int         =				input("Enter message: "			)

		snake_case_ :							List[Any]         =				dencrypt(_a     ,					13			)
		print("Encryption:"     ,					_a			)

		snake_case_ :							int         =				dencrypt(_a     ,					13			)
		print("Decryption: "     ,					_a			)


if __name__ == "__main__":
							import doctest

							doctest.testmod()
							main()
