




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 VivitImageProcessor





class 			__lowerCamelCase	(   unittest.TestCase   ):




    """simple docstring"""

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

     lowerCAmelCase__          =			parent
     lowerCAmelCase__          =			batch_size
     lowerCAmelCase__          =			num_channels
     lowerCAmelCase__          =			num_frames
     lowerCAmelCase__          =			image_size
     lowerCAmelCase__          =			min_resolution
     lowerCAmelCase__          =			max_resolution
     lowerCAmelCase__          =			do_resize
     lowerCAmelCase__          =			size
     lowerCAmelCase__          =			do_normalize
     lowerCAmelCase__          =			image_mean
     lowerCAmelCase__          =			image_std
     lowerCAmelCase__          =			crop_size


    def        a				(	self					:					Any       )				->	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 			__lowerCamelCase	(   _UpperCamelCase     ,    unittest.TestCase   ):




    """simple docstring"""

    snake_case__ =				VivitImageProcessor if is_vision_available() else None


    def        a				(	self					:					int       )				->	Union[str, Any]:
     lowerCAmelCase__          =			VivitImageProcessingTester(self       )


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


    def        a				(	self					:					List[str]       )				->	List[str]:
     lowerCAmelCase__          =			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       ,     "do_center_crop"       )       )
     self.assertTrue(hasattr(_SCREAMING_SNAKE_CASE       ,     "size"       )       )


    def        a				(	self					:					Union[str, Any]       )				->	Optional[Any]:
     lowerCAmelCase__          =			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}       )

     lowerCAmelCase__          =			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        a				(	self					:					List[str]       )				->	Dict:
     # Initialize image_processing
     lowerCAmelCase__          =			self.image_processing_class(**self.image_processor_dict       )
     # create random PIL videos
     lowerCAmelCase__          =			prepare_video_inputs(self.image_processor_tester       ,     equal_resolution=_SCREAMING_SNAKE_CASE       )
     for video in video_inputs:
      self.assertIsInstance(_SCREAMING_SNAKE_CASE       ,     _SCREAMING_SNAKE_CASE       )
      self.assertIsInstance(video[0]       ,     Image.Image       )

     # Test not batched input
     lowerCAmelCase__          =			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
     lowerCAmelCase__          =			image_processing(_SCREAMING_SNAKE_CASE       ,     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        a				(	self					:					Optional[Any]       )				->	Optional[Any]:
     # Initialize image_processing
     lowerCAmelCase__          =			self.image_processing_class(**self.image_processor_dict       )
     # create random numpy tensors
     lowerCAmelCase__          =			prepare_video_inputs(self.image_processor_tester       ,     equal_resolution=_SCREAMING_SNAKE_CASE       ,     numpify=_SCREAMING_SNAKE_CASE       )
     for video in video_inputs:
      self.assertIsInstance(_SCREAMING_SNAKE_CASE       ,     _SCREAMING_SNAKE_CASE       )
      self.assertIsInstance(video[0]       ,     np.ndarray       )

     # Test not batched input
     lowerCAmelCase__          =			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
     lowerCAmelCase__          =			image_processing(_SCREAMING_SNAKE_CASE       ,     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        a				(	self					:					Tuple       )				->	str:
     # Initialize image_processing
     lowerCAmelCase__          =			self.image_processing_class(**self.image_processor_dict       )
     # create random PyTorch tensors
     lowerCAmelCase__          =			prepare_video_inputs(self.image_processor_tester       ,     equal_resolution=_SCREAMING_SNAKE_CASE       ,     torchify=_SCREAMING_SNAKE_CASE       )
     for video in video_inputs:
      self.assertIsInstance(_SCREAMING_SNAKE_CASE       ,     _SCREAMING_SNAKE_CASE       )
      self.assertIsInstance(video[0]       ,     torch.Tensor       )

     # Test not batched input
     lowerCAmelCase__          =			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
     lowerCAmelCase__          =			image_processing(_SCREAMING_SNAKE_CASE       ,     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"],
         )       ,     )






import string



def 							_A       (						lowerCAmelCase_					: str      ):
     """simple docstring"""

     for key in range(len(string.ascii_uppercase      )      ):
          lowerCAmelCase__          =			""
          for symbol in message:
               if symbol in string.ascii_uppercase:
                    lowerCAmelCase__          =			string.ascii_uppercase.find(lowerCAmelCase_      )
                    lowerCAmelCase__          =			num - key
                    if num < 0:
                         lowerCAmelCase__          =			num + len(string.ascii_uppercase      )
                    lowerCAmelCase__          =			translated + string.ascii_uppercase[num]
               else:
                    lowerCAmelCase__          =			translated + symbol
          print(F'Decryption using Key #{key}: {translated}'      )



def 							_A       (						):
     """simple docstring"""

     lowerCAmelCase__          =			input("Encrypted message: "      )
     lowerCAmelCase__          =			message.upper()
     decrypt(lowerCAmelCase_      )


if __name__ == "__main__":
     import doctest

     doctest.testmod()
     main()
