code: 
  
  
  
  
  
  import inspect
  import json
  import os
  import tempfile
  import unittest
  
  from transformers.models.speech_to_text_a import SpeechaTextaTokenizer
  from transformers.models.speech_to_text_a.tokenization_speech_to_text_a import VOCAB_FILES_NAMES
  
  from ...test_tokenization_common import TokenizerTesterMixin
  
  
  
  
  
  
  
  class        __lowerCAmelCase (					UpperCamelCase__		,       unittest.TestCase):
        _lowercase       :      Union[str, Any]        =    SpeechaTextaTokenizer
        _lowercase       :      List[str]        =    False
  
  
  
  
  
  
  
        def      _lowercase						(					self							)     ->		int:
  
  
  
          '''simple docstring'''
  
  
  
  
          super().setUp()
  
          a__			:      int            ="<s> <pad> </s> <unk> here@@ a couple of@@ words for the he@@ re@@ vocab".split(" "							)
          a__			:      str            =["he re</w> 123", "here a 1456"]
          a__			:      Any            =dict(zip(lowerCAmelCase__	,   range(len(lowerCAmelCase__							)							)							)							)
  
          a__			:      Optional[int]            ={"pad_token": "<pad>", "unk_token": "<unk>", "bos_token": "<s>", "eos_token": "</s>"}
  
          a__			:      Union[str, Any]            =tempfile.mkdtemp()
          a__			:      int            =os.path.join(self.tmpdirname	,   VOCAB_FILES_NAMES["vocab_file"]							)
          a__			:      List[str]            =os.path.join(self.tmpdirname	,   VOCAB_FILES_NAMES["merges_file"]							)
  
          with open(self.vocab_file	,   "w"	,   encoding="utf-8"							) as fp:
            fp.write(json.dumps(lowerCAmelCase__							) + "\n"							)
  
          with open(self.merges_file	,   "w"							) as fp:
            fp.write("\n".join(lowerCAmelCase__							)							)
  
  
  
  
  
  
  
        def      _lowercase						(					self							)     ->		int:
  
  
  
          '''simple docstring'''
  
  
  
  
          a__			:      Optional[Any]            =list(self.get_tokenizer().get_vocab().keys()							)
  
          self.assertEqual(vocab_keys[0]	,   "<s>"							)
          self.assertEqual(vocab_keys[1]	,   "<pad>"							)
          self.assertEqual(vocab_keys[-1]	,   "vocab"							)
          self.assertEqual(len(lowerCAmelCase__							)	,   1_4							)
  
  
  
  
  
  
  
        def      _lowercase						(					self							)     ->		Optional[Any]:
  
  
  
          '''simple docstring'''
  
  
  
  
          self.assertEqual(self.get_tokenizer().vocab_size	,   1_4							)
  
  
  
  
  
  
  
        def      _lowercase						(					self							)     ->		Optional[int]:
  
  
  
          '''simple docstring'''
  
  
  
  
          a__			:      List[Any]            =SpeechaTextaTokenizer.from_pretrained(self.tmpdirname							)
  
          # make sure @@ is correctly concatenated
          a__			:      List[str]            =[4, 6, 8, 7, 1_0]  # ["here@@", "couple", "words", "of@@", "the"]
          a__			:      Any            =tokenizer.decode(lowerCAmelCase__							)
  
          self.assertTrue(output_string == "herecouple words ofthe"							)
  
  
  
  
  
  
  
        def      _lowercase						(					self							)     ->		Optional[Any]:
  
  
  
          '''simple docstring'''
  
  
  
  
          a__			:      Dict            =SpeechaTextaTokenizer.from_pretrained(self.tmpdirname							)
  
          with tempfile.TemporaryDirectory() as tmp_dirname:
            tokenizer.save_pretrained(lowerCAmelCase__							)
            os.remove(os.path.join(lowerCAmelCase__	,   "merges.txt"							)							)
  
            # load tokenizer without merges file should not throw an error
            a__			:      Any            =SpeechaTextaTokenizer.from_pretrained(lowerCAmelCase__							)
  
          with tempfile.TemporaryDirectory() as tmp_dirname:
            # save tokenizer and load again
            tokenizer.save_pretrained(lowerCAmelCase__							)
            a__			:      Optional[int]            =SpeechaTextaTokenizer.from_pretrained(lowerCAmelCase__							)
  
          self.assertIsNotNone(lowerCAmelCase__							)
  
  
  
  
  
  
  
        def      _lowercase						(					self							)     ->		Optional[int]:
  
  
  
          '''simple docstring'''
  
  
  
  
          if not self.test_slow_tokenizer:
            return
  
          a__			:      List[Any]            =inspect.signature(self.tokenizer_class.__init__							)
          a__			:      List[str]            =self.get_tokenizer()
  
          for parameter_name, parameter in signature.parameters.items():
            if parameter.default != inspect.Parameter.empty and parameter_name != "merges_file":
              self.assertIn(lowerCAmelCase__	,   tokenizer.init_kwargs							)
  
  
  
  
  
  
  
style_context: 
  
  
  
  
  
  from __future__ import annotations
  def   _A (	SCREAMING_SNAKE_CASE  :     str , SCREAMING_SNAKE_CASE  :     dict[str, str]		):
  
  
  
  
  
    """simple docstring"""
  
  
  
    a__      ,							a__      ,							a__			:      Optional[int]            ="", "", ""
    a__			:      str            =[]
  
    for character in message_part:
      tmp.append(character_to_number[character]		)
  
    for each in tmp:
      one += each[0]
      two += each[1]
      three += each[2]
  
    return one + two + three
  def   _A (	SCREAMING_SNAKE_CASE  :     str , SCREAMING_SNAKE_CASE  :     dict[str, str]		):
  
  
  
  
  
    """simple docstring"""
  
  
  
    a__      ,							a__			:      Any            ="", ""
    a__			:      Optional[int]            =[]
  
    for character in message_part:
      this_part += character_to_number[character]
  
    for digit in this_part:
      tmp += digit
      if len(SCREAMING_SNAKE_CASE		) == len(SCREAMING_SNAKE_CASE		):
        result.append(SCREAMING_SNAKE_CASE		)
        a__			:      str            =""
  
    return result[0], result[1], result[2]
  def   _A (	SCREAMING_SNAKE_CASE  :     str , SCREAMING_SNAKE_CASE  :     str		):
  
  
  
  
  
    """simple docstring"""
  
  
  
    a__			:      Optional[Any]            =alphabet.replace(" " , ""		).upper()
    a__			:      List[str]            =message.replace(" " , ""		).upper()
  
    # Check length and characters
    if len(SCREAMING_SNAKE_CASE		) != 27:
      raise KeyError("Length of alphabet has to be 27."		)
    for each in message:
      if each not in alphabet:
        raise ValueError("Each message character has to be included in alphabet!"		)
  
      # Generate dictionares
    a__			:      Any            =(
        "111",
        "112",
        "113",
        "121",
        "122",
        "123",
        "131",
        "132",
        "133",
        "211",
        "212",
        "213",
        "221",
        "222",
        "223",
        "231",
        "232",
        "233",
        "311",
        "312",
        "313",
        "321",
        "322",
        "323",
        "331",
        "332",
        "333",
    )
    a__			:      Tuple            ={}
    a__			:      List[str]            ={}
    for letter, number in zip(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE		):
      a__			:      Dict            =number
      a__			:      Union[str, Any]            =letter
  
    return message, alphabet, character_to_number, number_to_character
  def   _A (	SCREAMING_SNAKE_CASE  :     str , SCREAMING_SNAKE_CASE  :     str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ." , SCREAMING_SNAKE_CASE  :     int = 5		):
  
  
  
  
  
    """simple docstring"""
  
  
  
    a__      ,							a__      ,							a__      ,							a__			:      Union[str, Any]            =__prepare(
        SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE		)
    a__      ,							a__			:      Union[str, Any]            ="", ""
  
    for i in range(0 , len(SCREAMING_SNAKE_CASE		) + 1 , SCREAMING_SNAKE_CASE		):
      encrypted_numeric += __encrypt_part(
          message[i : i + period] , SCREAMING_SNAKE_CASE		)
  
    for i in range(0 , len(SCREAMING_SNAKE_CASE		) , 3		):
      encrypted += number_to_character[encrypted_numeric[i : i + 3]]
  
    return encrypted
  def   _A (	SCREAMING_SNAKE_CASE  :     str , SCREAMING_SNAKE_CASE  :     str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ." , SCREAMING_SNAKE_CASE  :     int = 5		):
  
  
  
  
  
    """simple docstring"""
  
  
  
    a__      ,							a__      ,							a__      ,							a__			:      Dict            =__prepare(
        SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE		)
    a__			:      Optional[Any]            =[]
    a__			:      Any            =""
  
    for i in range(0 , len(SCREAMING_SNAKE_CASE		) + 1 , SCREAMING_SNAKE_CASE		):
      a__      ,							a__      ,							a__			:      Union[str, Any]            =__decrypt_part(message[i : i + period] , SCREAMING_SNAKE_CASE		)
  
      for j in range(0 , len(SCREAMING_SNAKE_CASE		)		):
        decrypted_numeric.append(a[j] + b[j] + c[j]		)
  
    for each in decrypted_numeric:
      decrypted += number_to_character[each]
  
    return decrypted
  
  
  if __name__ == "__main__":
       UpperCAmelCase			:			List[str]	  = """DEFEND THE EAST WALL OF THE CASTLE."""
       UpperCAmelCase			:			Optional[Any]	  = encrypt_message(msg, """EPSDUCVWYM.ZLKXNBTFGORIJHAQ""")
       UpperCAmelCase			:			Optional[int]	  = decrypt_message(encrypted, """EPSDUCVWYM.ZLKXNBTFGORIJHAQ""")
       print(F"""Encrypted: {encrypted}\nDecrypted: {decrypted}""")
  
  
  
  
  
  
  