



'''simple docstring'''






import string

import numpy
def 				lowerCamelCase__	(						_A			,      _A    ):
  return b if a == 0 else greatest_common_divisor(b % a			,      _A    )

class 							a__:
    lowercase__			=   string.ascii_uppercase + string.digits
    # This cipher takes alphanumerics into account
    # i.e. a total of 36 characters

    # take x and return x % len(key_string)
    lowercase__			=   numpy.vectorize(lambda lowerCamelCase__     : x % 36     )

    lowercase__			=   numpy.vectorize(lowerCamelCase__     )







    def __init__(				self			:  Any						,      __snake_case			:  numpy.ndarray     ):
      a						: Optional[Any]					       =					self.modulus(__snake_case     )  # mod36 calc's on the encrypt key
      self.check_determinant()  # validate the determinant of the encryption key
      a						: Union[str, Any]					       =					encrypt_key.shape[0]







    def       lowercase_	(				self			:  Optional[Any]						,      __snake_case			:  str     ):
      return self.key_string.index(__snake_case     )







    def       lowercase_	(				self			:  Dict						,      __snake_case			:  int     ):
      return self.key_string[round(__snake_case     )]







    def       lowercase_	(				self			:  Any     ):
      a						: Tuple					       =					round(numpy.linalg.det(self.encrypt_key     )     )

      if det < 0:
        a						: List[str]					       =					det % len(self.key_string     )

      a						: Any					       =					len(self.key_string     )
      if greatest_common_divisor(__snake_case						,      len(self.key_string     )     ) != 1:
        a						: Any					       =					(
            F"""determinant modular {req_l} of encryption key({det}) """
            F"""is not co prime w.r.t {req_l}.\nTry another key."""
        )
        raise ValueError(__snake_case     )







    def       lowercase_	(				self			:  int						,      __snake_case			:  str     ):
      a						: Dict					       =					[char for char in text.upper() if char in self.key_string]

      a						: Optional[int]					       =					chars[-1]
      while len(__snake_case     ) % self.break_key != 0:
        chars.append(__snake_case     )

      return "".join(__snake_case     )







    def       lowercase_	(				self			:  Optional[Any]						,      __snake_case			:  str     ):
      a						: str					       =					self.process_text(text.upper()     )
      a						: Optional[Any]					       =					''

      for i in range(0						,      len(__snake_case     ) - self.break_key + 1						,      self.break_key     ):
        a						: List[str]					       =					text[i : i + self.break_key]
        a						: Optional[Any]					       =					[self.replace_letters(__snake_case     ) for char in batch]
        a						: Dict					       =					numpy.array([vec]     ).T
        a						: str					       =					self.modulus(self.encrypt_key.dot(__snake_case     )     ).T.tolist()[
            0
        ]
        a						: Any					       =					''.join(
            self.replace_digits(__snake_case     ) for num in batch_encrypted     )
        encrypted += encrypted_batch

      return encrypted







    def       lowercase_	(				self			:  Optional[int]     ):
      a						: Tuple					       =					round(numpy.linalg.det(self.encrypt_key     )     )

      if det < 0:
        a						: Optional[int]					       =					det % len(self.key_string     )
      a						: Any					       =					None
      for i in range(len(self.key_string     )     ):
        if (det * i) % len(self.key_string     ) == 1:
          a						: Union[str, Any]					       =					i
          break

      a						: List[Any]					       =					(
          det_inv
          * numpy.linalg.det(self.encrypt_key     )
          * numpy.linalg.inv(self.encrypt_key     )
      )

      return self.to_int(self.modulus(__snake_case     )     )







    def       lowercase_	(				self			:  Optional[Any]						,      __snake_case			:  str     ):
      a						: List[str]					       =					self.make_decrypt_key()
      a						: Union[str, Any]					       =					self.process_text(text.upper()     )
      a						: Tuple					       =					''

      for i in range(0						,      len(__snake_case     ) - self.break_key + 1						,      self.break_key     ):
        a						: Union[str, Any]					       =					text[i : i + self.break_key]
        a						: int					       =					[self.replace_letters(__snake_case     ) for char in batch]
        a						: Union[str, Any]					       =					numpy.array([vec]     ).T
        a						: int					       =					self.modulus(decrypt_key.dot(__snake_case     )     ).T.tolist()[0]
        a						: List[Any]					       =					''.join(
            self.replace_digits(__snake_case     ) for num in batch_decrypted     )
        decrypted += decrypted_batch

      return decrypted
def 				lowerCamelCase__	(						):
  a						: int					       =					int(input('Enter the order of the encryption key: '    )    )
  a						: Union[str, Any]					       =					[]

  print('Enter each row of the encryption key with space separated integers'    )
  for _ in range(_A    ):
    a						: int					       =					[int(_A    ) for x in input().split()]
    hill_matrix.append(_A    )

  a						: Optional[Any]					       =					HillCipher(numpy.array(_A    )    )

  print('Would you like to encrypt or decrypt some text? (1 or 2)'    )
  a						: Optional[Any]					       =					input('\n1. Encrypt\n2. Decrypt\n'    )
  if option == "1":
    a						: Any					       =					input('What text would you like to encrypt?: '    )
    print('Your encrypted text is:'    )
    print(hc.encrypt(_A    )    )
  elif option == "2":
    a						: Optional[Any]					       =					input('What text would you like to decrypt?: '    )
    print('Your decrypted text is:'    )
    print(hc.decrypt(_A    )    )


if __name__ == "__main__":
     import doctest

     doctest.testmod()

     main()




'''simple docstring'''






from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_tokenizers_available,
    is_torch_available,
)


lowerCAmelCase: List[Any]							=						{}

try:
     if not is_sentencepiece_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     lowerCAmelCase: Optional[int]							=						['NllbTokenizer']

try:
     if not is_tokenizers_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     lowerCAmelCase: Dict							=						['NllbTokenizerFast']


if TYPE_CHECKING:
     try:
          if not is_sentencepiece_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .tokenization_nllb import NllbTokenizer

     try:
          if not is_tokenizers_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .tokenization_nllb_fast import NllbTokenizerFast

else:
     import sys

     lowerCAmelCase: Tuple							=						_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)