




__SCREAMING_SNAKE_CASE     : Optional[int]      ={
    """A""": ("""ABCDEFGHIJKLM""", """NOPQRSTUVWXYZ"""),
    """B""": ("""ABCDEFGHIJKLM""", """NOPQRSTUVWXYZ"""),
    """C""": ("""ABCDEFGHIJKLM""", """ZNOPQRSTUVWXY"""),
    """D""": ("""ABCDEFGHIJKLM""", """ZNOPQRSTUVWXY"""),
    """E""": ("""ABCDEFGHIJKLM""", """YZNOPQRSTUVWX"""),
    """F""": ("""ABCDEFGHIJKLM""", """YZNOPQRSTUVWX"""),
    """G""": ("""ABCDEFGHIJKLM""", """XYZNOPQRSTUVW"""),
    """H""": ("""ABCDEFGHIJKLM""", """XYZNOPQRSTUVW"""),
    """I""": ("""ABCDEFGHIJKLM""", """WXYZNOPQRSTUV"""),
    """J""": ("""ABCDEFGHIJKLM""", """WXYZNOPQRSTUV"""),
    """K""": ("""ABCDEFGHIJKLM""", """VWXYZNOPQRSTU"""),
    """L""": ("""ABCDEFGHIJKLM""", """VWXYZNOPQRSTU"""),
    """M""": ("""ABCDEFGHIJKLM""", """UVWXYZNOPQRST"""),
    """N""": ("""ABCDEFGHIJKLM""", """UVWXYZNOPQRST"""),
    """O""": ("""ABCDEFGHIJKLM""", """TUVWXYZNOPQRS"""),
    """P""": ("""ABCDEFGHIJKLM""", """TUVWXYZNOPQRS"""),
    """Q""": ("""ABCDEFGHIJKLM""", """STUVWXYZNOPQR"""),
    """R""": ("""ABCDEFGHIJKLM""", """STUVWXYZNOPQR"""),
    """S""": ("""ABCDEFGHIJKLM""", """RSTUVWXYZNOPQ"""),
    """T""": ("""ABCDEFGHIJKLM""", """RSTUVWXYZNOPQ"""),
    """U""": ("""ABCDEFGHIJKLM""", """QRSTUVWXYZNOP"""),
    """V""": ("""ABCDEFGHIJKLM""", """QRSTUVWXYZNOP"""),
    """W""": ("""ABCDEFGHIJKLM""", """PQRSTUVWXYZNO"""),
    """X""": ("""ABCDEFGHIJKLM""", """PQRSTUVWXYZNO"""),
    """Y""": ("""ABCDEFGHIJKLM""", """OPQRSTUVWXYZN"""),
    """Z""": ("""ABCDEFGHIJKLM""", """OPQRSTUVWXYZN"""),
}

def       lowerCAmelCase_      (	lowerCamelCase:							str    )       ->      str:


      '''simple docstring'''




      return [alphabet[char] for char in key.upper()]

def       lowerCAmelCase_      (	lowerCamelCase:							str  ,					lowerCamelCase:							str    )       ->      List[str]:


      '''simple docstring'''




      lowerCamelCase__   	=					''
      lowerCamelCase__   	=					0
      lowerCamelCase__   	=					generate_table(__lowercase    )
      for char in words.upper():
            cipher += get_opponent(table[count]  ,					__lowercase    )
            lowerCamelCase__   	=					(count + 1) % len(__lowercase    )
      return cipher

def       lowerCAmelCase_      (	lowerCamelCase:							str  ,					lowerCamelCase:							str    )       ->      Tuple:


      '''simple docstring'''




      return encrypt(__lowercase  ,					__lowercase    )

def       lowerCAmelCase_      (	lowerCamelCase:							tuple[str, str]  ,					lowerCamelCase:							str    )       ->      str:


      '''simple docstring'''




      lowerCamelCase__   	=					0 if char in table[0] else 1
      lowerCamelCase__   	=					table[row].index(__lowercase    )
      return row, col

def       lowerCAmelCase_      (	lowerCamelCase:							tuple[str, str]  ,					lowerCamelCase:							str    )       ->      Dict:


      '''simple docstring'''




      lowerCamelCase__	,		lowerCamelCase__   	=					get_position(__lowercase  ,					char.upper()    )
      if row == 1:
            return table[0][col]
      else:
            return table[1][col] if row == 0 else char


if __name__ == "__main__":
      import doctest

      doctest.testmod()  # Fist ensure that all our tests are passing...
      __SCREAMING_SNAKE_CASE     : List[str]      =input("""Enter key: """).strip()
      __SCREAMING_SNAKE_CASE     : Any      =input("""Enter text to encrypt: """).strip()
      __SCREAMING_SNAKE_CASE     : Any      =encrypt(key, text)

      print(F"""Encrypted: {cipher_text}""")
      print(F"""Decrypted with key: {decrypt(key, cipher_text)}""")






import os
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():
      import torch

      from transformers import GPTaLMHeadModel

@require_torch
@require_sentencepiece
@require_tokenizers
class 	__snake_case					(      unittest.TestCase ):






    '''simple docstring'''





    @slow
    @unittest.skip('''Model is not available.'''				)
    def 						A		( self    :		str				):

      """simple docstring"""





      __lowerCAmelCase								=					'''nvidia/megatron-gpt2-345m/'''
      if "MYDIR" in os.environ:
        __lowerCAmelCase								=					os.path.join(os.environ['''MYDIR''']      ,    snake_case				)
      __lowerCAmelCase								=					GPTaLMHeadModel.from_pretrained(snake_case				)
      model.to(snake_case				)
      model.half()

      __lowerCAmelCase								=					torch.tensor(
          [[101, 7_110, 1_005, 1_056, 2_023, 11_333, 17_413, 1_029, 102]]      ,    device=snake_case      ,    dtype=torch.long      ,    )

      with torch.no_grad():
        __lowerCAmelCase								=					model(snake_case				).logits

      __lowerCAmelCase								=					torch.Size((1, 9, 50_257)				)
      self.assertEqual(output.shape      ,    snake_case				)

      __lowerCAmelCase								=					torch.tensor(
          [
              4.9414,
              -0.2920,
              -1.2148,
              -4.0273,
              -0.5161,
              -5.2109,
              -1.2412,
              -1.8301,
              -1.7734,
              -4.7148,
              -0.2317,
              -1.0811,
              -2.1777,
              0.4141,
              -3.7969,
              -4.0586,
              -2.5332,
              -3.3809,
              4.3867,
          ]      ,    device=snake_case      ,    dtype=torch.half      ,    )

      for i in range(19				):
        __lowerCAmelCase						,    __lowerCAmelCase								=					8 * i // 17, 2_792 * i  # along the diagonal
        __lowerCAmelCase						,    __lowerCAmelCase								=					output[0, r, c], expected_diag[i]
        __lowerCAmelCase								=					f'''row={r} col={c} computed={computed} expected={expected}'''
        self.assertAlmostEqual(snake_case      ,    snake_case      ,    delta=1e-4      ,    msg=snake_case				)
