
import math




def        __UpperCamelCase					(    ):
 __a			:  Any		    =  input('''Enter message: '''  )
 __a			:  Union[str, Any]		    =  int(input(f"Enter key [2-{len(lowerCAmelCase__  ) - 1}]: "  )  )
 __a			:  Union[str, Any]		    =  input('''Encryption/Decryption [e/d]: '''  )

 if mode.lower().startswith('''e'''  ):
  __a			:  Any		    =  encrypt_message(lowerCAmelCase__  ,       lowerCAmelCase__  )
 elif mode.lower().startswith('''d'''  ):
  __a			:  Dict		    =  decrypt_message(lowerCAmelCase__  ,       lowerCAmelCase__  )

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




def        __UpperCamelCase					(    lowerCAmelCase__							:    int  ,       lowerCAmelCase__							:    str  ):
 __a			:  Tuple		    =  [''''''] * key
 for col in range(lowerCAmelCase__  ):
  __a			:  Dict		    =  col
  while pointer < len(lowerCAmelCase__  ):
   cipher_text[col] += message[pointer]
   pointer += key
 return "".join(lowerCAmelCase__  )




def        __UpperCamelCase					(    lowerCAmelCase__							:    int  ,       lowerCAmelCase__							:    str  ):
 __a			:  List[str]		    =  math.ceil(len(lowerCAmelCase__  ) / key  )
 __a			:  Dict		    =  key
 __a			:  Optional[int]		    =  (num_cols * num_rows) - len(lowerCAmelCase__  )
 __a			:  List[str]		    =  [''''''] * num_cols
 __a			:  Tuple		    =  0
 __a			:  Union[str, 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)
  ):
   __a			:  List[str]		    =  0
   row += 1

 return "".join(lowerCAmelCase__  )


if __name__ == "__main__":
      import doctest

      doctest.testmod()
      main()


import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device


if is_torch_available():
      from transformers import AutoModelForSeqaSeqLM, AutoTokenizer



@require_torch
@require_sentencepiece
@require_tokenizers
class 		UpperCamelCase__  (	unittest.TestCase   ):
   @slow
   def 				lowerCAmelCase      (self			: Tuple       ):
    __a			:  List[str]		    =  AutoModelForSeqaSeqLM.from_pretrained('''google/mt5-small''' ,    return_dict=snake_case_       ).to(snake_case_       )
    __a			:  List[Any]		    =  AutoTokenizer.from_pretrained('''google/mt5-small'''       )

    __a			:  Optional[int]		    =  tokenizer('''Hello there''' ,    return_tensors='''pt'''       ).input_ids
    __a			:  Dict		    =  tokenizer('''Hi I am''' ,    return_tensors='''pt'''       ).input_ids

    __a			:  Optional[Any]		    =  model(input_ids.to(snake_case_       ) ,    labels=labels.to(snake_case_       )       ).loss
    __a			:  Tuple		    =  -(labels.shape[-1] * loss.item())

    __a			:  Dict		    =  -84.9127
    self.assertTrue(abs(mtf_score - EXPECTED_SCORE       ) < 1E-4       )
