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


if is_torch_available():
    import torch

if is_vision_available():
    from PIL import Image

    from transformers import TvltImageProcessor



def 				a__			(					lowerCAmelCase						:							Optional[Any]							,     lowerCAmelCase						:							str=10							,     lowerCAmelCase						:							Dict=10							,     lowerCAmelCase						:							List[Any]=False							,     lowerCAmelCase						:							str=False		):






     '''simple docstring'''
     UpperCAmelCase__				:			Optional[int]							=    []
     for i in range(image_processor_tester.num_frames		):
          video.append(np.random.randint(255							,     size=(image_processor_tester.num_channels, width, height)							,     dtype=np.uinta		)		)

     if not numpify and not torchify:
          # PIL expects the channel dimension as last dimension
          UpperCAmelCase__				:			Tuple							=    [Image.fromarray(np.moveaxis(lowerCAmelCase							,     0							,     -1		)		) for frame in video]

     if torchify:
          UpperCAmelCase__				:			str							=    [torch.from_numpy(lowerCAmelCase		) for frame in video]

     return video



def 				a__			(					lowerCAmelCase						:							List[str]							,     lowerCAmelCase						:							Optional[int]=False							,     lowerCAmelCase						:							Optional[int]=False							,     lowerCAmelCase						:							Any=False		):






     '''simple docstring'''
     assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

     UpperCAmelCase__				:			List[Any]							=    []
     for i in range(image_processor_tester.batch_size		):
          if equal_resolution:
               UpperCAmelCase__				:			List[Any]							=    image_processor_tester.max_resolution
          else:
               UpperCAmelCase__				,						UpperCAmelCase__				:			str							=    np.random.choice(
                   np.arange(image_processor_tester.min_resolution							,     image_processor_tester.max_resolution		)							,     2		)
               UpperCAmelCase__				:			Union[str, Any]							=    prepare_video(
                   image_processor_tester=lowerCAmelCase							,     width=lowerCAmelCase							,     height=lowerCAmelCase							,     numpify=lowerCAmelCase							,     torchify=lowerCAmelCase							,     )
          video_inputs.append(lowerCAmelCase		)

     return video_inputs







class 	_lowercase    (							unittest.TestCase					):


     '''simple docstring'''





     def __init__(   self			,      __UpperCamelCase			,      __UpperCamelCase=7			,      __UpperCamelCase=3			,      __UpperCamelCase=4			,      __UpperCamelCase=18			,      __UpperCamelCase=30			,      __UpperCamelCase=4_00			,      __UpperCamelCase=True			,      __UpperCamelCase=None			,      __UpperCamelCase=True			,      __UpperCamelCase=[0.5, 0.5, 0.5]			,      __UpperCamelCase=[0.5, 0.5, 0.5]			,      __UpperCamelCase=True			,      __UpperCamelCase=None			,      )->       int:
          UpperCAmelCase__				:			Optional[Any]							=    size if size is not None else {"shortest_edge": 18}
          UpperCAmelCase__				:			Optional[int]							=    crop_size if crop_size is not None else {"height": 18, "width": 18}

          UpperCAmelCase__				:			Any							=    parent
          UpperCAmelCase__				:			Dict							=    batch_size
          UpperCAmelCase__				:			Dict							=    num_channels
          UpperCAmelCase__				:			Optional[Any]							=    num_frames
          UpperCAmelCase__				:			Dict							=    image_size
          UpperCAmelCase__				:			Any							=    min_resolution
          UpperCAmelCase__				:			int							=    max_resolution
          UpperCAmelCase__				:			Optional[int]							=    do_resize
          UpperCAmelCase__				:			str							=    size
          UpperCAmelCase__				:			List[str]							=    do_normalize
          UpperCAmelCase__				:			List[Any]							=    image_mean
          UpperCAmelCase__				:			Dict							=    image_std
          UpperCAmelCase__				:			str							=    do_center_crop
          UpperCAmelCase__				:			Any							=    crop_size



     def 			lowerCAmelCase__							(   self	)->       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,
              "do_center_crop": self.do_center_crop,
              "crop_size": self.crop_size,
          }







@require_torch
@require_vision
class 	_lowercase    (							lowerCAmelCase_						, unittest.TestCase					):


     '''simple docstring'''





     _A		    =				TvltImageProcessor if is_vision_available() else None



     def 			lowerCAmelCase__							(   self	)->       int:
          UpperCAmelCase__				:			List[str]							=    TvltImageProcessorTester(self	)



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



     def 			lowerCAmelCase__							(   self	)->       Optional[int]:
          UpperCAmelCase__				:			Any							=    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			,      "do_center_crop"	)	)
          self.assertTrue(hasattr(__UpperCamelCase			,      "size"	)	)



     def 			lowerCAmelCase__							(   self	)->       int:
          # Initialize image_processor
          UpperCAmelCase__				:			Optional[int]							=    self.image_processing_class(**self.image_processor_dict	)
          # create random PIL videos
          UpperCAmelCase__				:			List[Any]							=    prepare_video_inputs(self.image_processor_tester			,      equal_resolution=__UpperCamelCase	)
          for video in video_inputs:
               self.assertIsInstance(__UpperCamelCase			,      __UpperCamelCase	)
               self.assertIsInstance(video[0]			,      Image.Image	)

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

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

          # Test not batched input
          UpperCAmelCase__				:			List[Any]							=    image_processor(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
          UpperCAmelCase__				:			str							=    image_processor(__UpperCamelCase			,      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"],
              )			,      )





"""simple docstring"""




def 				a__			(					lowerCAmelCase						:							str							,     lowerCAmelCase						:							int = 13		):






     '''simple docstring'''
     UpperCAmelCase__				:			Any							=    ""
     for c in s:
          if "A" <= c <= "Z":
               out += chr(ord("A"		) + (ord(lowerCAmelCase		) - ord("A"		) + n) % 26		)
          elif "a" <= c <= "z":
               out += chr(ord("a"		) + (ord(lowerCAmelCase		) - ord("a"		) + n) % 26		)
          else:
               out += c
     return out



def 				a__			(					):






     '''simple docstring'''
     UpperCAmelCase__				:			Optional[int]							=    input("Enter message: "		)

     UpperCAmelCase__				:			Optional[Any]							=    dencrypt(lowerCAmelCase							,     13		)
     print("Encryption:"							,     lowerCAmelCase		)

     UpperCAmelCase__				:			List[str]							=    dencrypt(lowerCAmelCase							,     13		)
     print("Decryption: "							,     lowerCAmelCase		)


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    main()



