






'''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_video_inputs


if is_torch_available():
   import torch

if is_vision_available():
   from PIL import Image

   from transformers import VivitImageProcessor







class 	SCREAMING_SNAKE_CASE	(      unittest.TestCase  ):




       def __init__(					self      : List[Any]	,    A__      : Optional[int]	,    A__      : Any=7	,    A__      : Dict=3	,    A__      : Dict=10	,    A__      : Optional[int]=18	,    A__      : Any=30	,    A__      : Dict=400	,    A__      : List[str]=True	,    A__      : int=None	,    A__      : List[Any]=True	,    A__      : Optional[int]=[0.5, 0.5, 0.5]	,    A__      : Union[str, Any]=[0.5, 0.5, 0.5]	,    A__      : int=None	,    ):


            """simple docstring"""







            __lowerCamelCase						:       Union[str, Any]				   =				size if size is not None else {"""shortest_edge""": 18}
            __lowerCamelCase						:       Tuple				   =				crop_size if crop_size is not None else {"""height""": 18, """width""": 18}

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




       def 					a_					(					self      : str					):


            """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,
                "crop_size": self.crop_size,
            }







@require_torch
@require_vision
class 	SCREAMING_SNAKE_CASE	(      lowerCAmelCase_    ,   unittest.TestCase  ):
       snake_case__    :     Dict   		=			VivitImageProcessor if is_vision_available() else None




       def 					a_					(					self      : Any					):


            """simple docstring"""







            __lowerCamelCase						:       str				   =				VivitImageProcessingTester(self					)




       @property
       def 					a_					(					self      : List[Any]					):


            """simple docstring"""







            return self.image_processor_tester.prepare_image_processor_dict()




       def 					a_					(					self      : int					):


            """simple docstring"""







            __lowerCamelCase						:       int				   =				self.image_processing_class(**self.image_processor_dict					)
            self.assertTrue(hasattr(A__	,    """image_mean"""					)					)
            self.assertTrue(hasattr(A__	,    """image_std"""					)					)
            self.assertTrue(hasattr(A__	,    """do_normalize"""					)					)
            self.assertTrue(hasattr(A__	,    """do_resize"""					)					)
            self.assertTrue(hasattr(A__	,    """do_center_crop"""					)					)
            self.assertTrue(hasattr(A__	,    """size"""					)					)




       def 					a_					(					self      : Any					):


            """simple docstring"""







            __lowerCamelCase						:       Any				   =				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						:       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 					a_					(					self      : Any					):


            """simple docstring"""







            __lowerCamelCase						:       List[Any]				   =				self.image_processing_class(**self.image_processor_dict					)
            # create random PIL videos
            __lowerCamelCase						:       Any				   =				prepare_video_inputs(self.image_processor_tester	,    equal_resolution=A__					)
            for video in video_inputs:
                 self.assertIsInstance(A__	,    A__					)
                 self.assertIsInstance(video[0]	,    Image.Image					)

            # Test not batched input
            __lowerCamelCase						:       Dict				   =				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						:       Optional[int]				   =				image_processing(A__	,    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      : Union[str, Any]					):


            """simple docstring"""







            __lowerCamelCase						:       Dict				   =				self.image_processing_class(**self.image_processor_dict					)
            # create random numpy tensors
            __lowerCamelCase						:       int				   =				prepare_video_inputs(self.image_processor_tester	,    equal_resolution=A__	,    numpify=A__					)
            for video in video_inputs:
                 self.assertIsInstance(A__	,    A__					)
                 self.assertIsInstance(video[0]	,    np.ndarray					)

            # Test not batched input
            __lowerCamelCase						:       Tuple				   =				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						:       str				   =				image_processing(A__	,    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]					):


            """simple docstring"""







            __lowerCamelCase						:       List[Any]				   =				self.image_processing_class(**self.image_processor_dict					)
            # create random PyTorch tensors
            __lowerCamelCase						:       List[str]				   =				prepare_video_inputs(self.image_processor_tester	,    equal_resolution=A__	,    torchify=A__					)
            for video in video_inputs:
                 self.assertIsInstance(A__	,    A__					)
                 self.assertIsInstance(video[0]	,    torch.Tensor					)

            # Test not batched input
            __lowerCamelCase						:       Optional[Any]				   =				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						:       Optional[int]				   =				image_processing(A__	,    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'''

import math
def     __lowercase  ()   ->     None:


     """simple docstring"""
     __lowerCamelCase						:       Optional[int]				   =				input("""Enter message: """     )
     __lowerCamelCase						:       Optional[Any]				   =				int(input(f"Enter key [2-{len(_lowercase     ) - 1}]: "     )     )
     __lowerCamelCase						:       Dict				   =				input("""Encryption/Decryption [e/d]: """     )

     if mode.lower().startswith("""e"""     ):
          __lowerCamelCase						:       Any				   =				encrypt_message(_lowercase,						_lowercase     )
     elif mode.lower().startswith("""d"""     ):
          __lowerCamelCase						:       int				   =				decrypt_message(_lowercase,						_lowercase     )

     # Append pipe symbol (vertical bar) to identify spaces at the end.
     print(f"Output:\n{text + '|'}"     )
def     __lowercase  (_lowercase,						_lowercase     )   ->     str:


     """simple docstring"""
     __lowerCamelCase						:       int				   =				[""""""] * key
     for col in range(_lowercase     ):
          __lowerCamelCase						:       Optional[Any]				   =				col
          while pointer < len(_lowercase     ):
               cipher_text[col] += message[pointer]
               pointer += key
     return "".join(_lowercase     )
def     __lowercase  (_lowercase,						_lowercase     )   ->     str:


     """simple docstring"""
     __lowerCamelCase						:       List[str]				   =				math.ceil(len(_lowercase     ) / key     )
     __lowerCamelCase						:       List[str]				   =				key
     __lowerCamelCase						:       Tuple				   =				(num_cols * num_rows) - len(_lowercase     )
     __lowerCamelCase						:       List[str]				   =				[""""""] * num_cols
     __lowerCamelCase						:       List[str]				   =				0
     __lowerCamelCase						:       List[Any]				   =				0

     for symbol in message:
          plain_text[col] += symbol
          col += 1

          if (
              (col == num_cols)
              or (col == num_cols - 1)
              and (row >= num_rows - num_shaded_boxes)
          ):
               __lowerCamelCase						:       int				   =				0
               row += 1

     return "".join(_lowercase     )


if __name__ == "__main__":
   import doctest

   doctest.testmod()
   main()



