
"""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,						__lowerCamelCase=10,						__lowerCamelCase=10,						__lowerCamelCase=False,						__lowerCamelCase=False    ):
   UpperCAmelCase_   :   List[Any]     	=       []
   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_   :   str     	=       [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,						__lowerCamelCase=False,						__lowerCamelCase=False,						__lowerCamelCase=False    ):
   assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

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

   return video_inputs


class A_      (unittest.TestCase ):




  '''simple docstring'''







  def __init__(						self							,  lowercase_							,  lowercase_=7							,  lowercase_=3							,  lowercase_=4							,  lowercase_=18							,  lowercase_=30							,  lowercase_=400							,  lowercase_=True							,  lowercase_=None							,  lowercase_=True							,  lowercase_=[0.5, 0.5, 0.5]							,  lowercase_=[0.5, 0.5, 0.5]							,  lowercase_=True							,  lowercase_=None							,  ):

     """simple docstring"""
     UpperCAmelCase_   :   Union[str, Any]     	=       size if size is not None else {"shortest_edge": 18}
     UpperCAmelCase_   :   int     	=       crop_size if crop_size is not None else {"height": 18, "width": 18}

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







  def 			UpperCamelCase__   (						self    ):

     """simple docstring"""
     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 A_      (lowercase__							,unittest.TestCase ):




  '''simple docstring'''
  SCREAMING_SNAKE_CASE__     :		Dict    	=						TvltImageProcessor if is_vision_available() else None







  def 			UpperCamelCase__   (						self    ):

     """simple docstring"""
     UpperCAmelCase_   :   str     	=       TvltImageProcessorTester(self    )







  @property
  def 			UpperCamelCase__   (						self    ):

     """simple docstring"""
     return self.image_processor_tester.prepare_image_processor_dict()







  def 			UpperCamelCase__   (						self    ):

     """simple docstring"""
     UpperCAmelCase_   :   Tuple     	=       self.image_processing_class(**self.image_processor_dict    )
     self.assertTrue(hasattr(lowercase_							,  "image_mean"    )    )
     self.assertTrue(hasattr(lowercase_							,  "image_std"    )    )
     self.assertTrue(hasattr(lowercase_							,  "do_normalize"    )    )
     self.assertTrue(hasattr(lowercase_							,  "do_resize"    )    )
     self.assertTrue(hasattr(lowercase_							,  "do_center_crop"    )    )
     self.assertTrue(hasattr(lowercase_							,  "size"    )    )







  def 			UpperCamelCase__   (						self    ):

     """simple docstring"""
     # Initialize image_processor
     UpperCAmelCase_   :   Optional[int]     	=       self.image_processing_class(**self.image_processor_dict    )
     # create random PIL videos
     UpperCAmelCase_   :   Union[str, Any]     	=       prepare_video_inputs(self.image_processor_tester							,  equal_resolution=lowercase_    )
     for video in video_inputs:
        self.assertIsInstance(lowercase_							,  lowercase_    )
        self.assertIsInstance(video[0]							,  Image.Image    )

     # 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_   :   int     	=       image_processor(lowercase_							,  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 			UpperCamelCase__   (						self    ):

     """simple docstring"""
     # Initialize image_processor
     UpperCAmelCase_   :   Tuple     	=       self.image_processing_class(**self.image_processor_dict    )
     # create random numpy tensors
     UpperCAmelCase_   :   List[Any]     	=       prepare_video_inputs(self.image_processor_tester							,  equal_resolution=lowercase_							,  numpify=lowercase_    )
     for video in video_inputs:
        self.assertIsInstance(lowercase_							,  lowercase_    )
        self.assertIsInstance(video[0]							,  np.ndarray    )

     # Test not batched input
     UpperCAmelCase_   :   Optional[int]     	=       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(lowercase_							,  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 			UpperCamelCase__   (						self    ):

     """simple docstring"""
     # Initialize image_processor
     UpperCAmelCase_   :   int     	=       self.image_processing_class(**self.image_processor_dict    )
     # create random PyTorch tensors
     UpperCAmelCase_   :   Optional[int]     	=       prepare_video_inputs(self.image_processor_tester							,  equal_resolution=lowercase_							,  torchify=lowercase_    )
     for video in video_inputs:
        self.assertIsInstance(lowercase_							,  lowercase_    )
        self.assertIsInstance(video[0]							,  torch.Tensor    )

     # Test not batched input
     UpperCAmelCase_   :   Tuple     	=       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(lowercase_							,  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,						__lowerCamelCase    ):
   if not isinstance(__lowerCamelCase,						__lowerCamelCase    ):
      raise TypeError("plaintext must be a string"    )
   if not isinstance(__lowerCamelCase,						__lowerCamelCase    ):
      raise TypeError("key must be a string"    )

   if not plaintext:
      raise ValueError("plaintext is empty"    )
   if not key:
      raise ValueError("key is empty"    )

   key += plaintext
   UpperCAmelCase_   :   Optional[int]     	=       plaintext.lower()
   UpperCAmelCase_   :   Any     	=       key.lower()
   UpperCAmelCase_   :   Optional[int]     	=       0
   UpperCAmelCase_   :   List[str]     	=       0
   UpperCAmelCase_   :   Optional[int]     	=       ""
   while plaintext_iterator < len(__lowerCamelCase    ):
      if (
          ord(plaintext[plaintext_iterator]    ) < 97
          or ord(plaintext[plaintext_iterator]    ) > 122
      ):
         ciphertext += plaintext[plaintext_iterator]
         plaintext_iterator += 1
      elif ord(key[key_iterator]    ) < 97 or ord(key[key_iterator]    ) > 122:
         key_iterator += 1
      else:
         ciphertext += chr(
             (
                 (ord(plaintext[plaintext_iterator]    ) - 97 + ord(key[key_iterator]    ))
                 - 97
             )
             % 26
             + 97    )
         key_iterator += 1
         plaintext_iterator += 1
   return ciphertext







def       __a	(						__lowerCamelCase,						__lowerCamelCase    ):
   if not isinstance(__lowerCamelCase,						__lowerCamelCase    ):
      raise TypeError("ciphertext must be a string"    )
   if not isinstance(__lowerCamelCase,						__lowerCamelCase    ):
      raise TypeError("key must be a string"    )

   if not ciphertext:
      raise ValueError("ciphertext is empty"    )
   if not key:
      raise ValueError("key is empty"    )

   UpperCAmelCase_   :   List[str]     	=       key.lower()
   UpperCAmelCase_   :   Tuple     	=       0
   UpperCAmelCase_   :   Optional[int]     	=       0
   UpperCAmelCase_   :   Dict     	=       ""
   while ciphertext_iterator < len(__lowerCamelCase    ):
      if (
          ord(ciphertext[ciphertext_iterator]    ) < 97
          or ord(ciphertext[ciphertext_iterator]    ) > 122
      ):
         plaintext += ciphertext[ciphertext_iterator]
      else:
         plaintext += chr(
             (ord(ciphertext[ciphertext_iterator]    ) - ord(key[key_iterator]    )) % 26
             + 97    )
         key += chr(
             (ord(ciphertext[ciphertext_iterator]    ) - ord(key[key_iterator]    )) % 26
             + 97    )
         key_iterator += 1
      ciphertext_iterator += 1
   return plaintext


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    _a									=				int(input('Type 1 to encrypt or 2 to decrypt:'))
    if operation == 1:
        _a									=				input('Typeplaintext to be encrypted:\n')
        _a									=				input('Type the key:\n')
        print(encrypt(plaintext, key))
    elif operation == 2:
        _a									=				input('Type the ciphertext to be decrypted:\n')
        _a									=				input('Type the key:\n')
        print(decrypt(ciphertext, key))
    decrypt('jsqqs avvwo', 'coffee')


