

import string

import numpy

def 						UpperCamelCase (lowercase_:			int   ,				lowercase_:			int )					->				int:
 return b if a == 0 else greatest_common_divisor(b % a   ,				lowercase_ )



class    _a						:


     '''simple docstring'''






     UpperCAmelCase__:       Any  							=	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)
     UpperCAmelCase__:       Tuple  							=	numpy.vectorize(lambda __magic_name__    : x % 36    )

     UpperCAmelCase__:       Union[str, Any]  							=	numpy.vectorize(__magic_name__    )






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






     def   __A      (			self   ,	A__      ):
      return self.key_string.index(A__      )






     def   __A      (			self   ,	A__      ):
      return self.key_string[round(A__      )]






     def   __A      (			self      ):
      A__							:   int					       =		round(numpy.linalg.det(self.encrypt_key      )      )

      if det < 0:
       A__							:   Any					       =		det % len(self.key_string      )

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






     def   __A      (			self   ,	A__      ):
      A__							:   int					       =		[char for char in text.upper() if char in self.key_string]

      A__							:   str					       =		chars[-1]
      while len(A__      ) % self.break_key != 0:
       chars.append(A__      )

      return "".join(A__      )






     def   __A      (			self   ,	A__      ):
      A__							:   Any					       =		self.process_text(text.upper()      )
      A__							:   Union[str, Any]					       =		""""""

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

      return encrypted






     def   __A      (			self      ):
      A__							:   int					       =		round(numpy.linalg.det(self.encrypt_key      )      )

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

      A__							:   Tuple					       =		(
          det_inv
          * numpy.linalg.det(self.encrypt_key      )
          * numpy.linalg.inv(self.encrypt_key      )
      )

      return self.to_int(self.modulus(A__      )      )






     def   __A      (			self   ,	A__      ):
      A__							:   Dict					       =		self.make_decrypt_key()
      A__							:   Any					       =		self.process_text(text.upper()      )
      A__							:   List[str]					       =		""""""

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

      return decrypted



def 						UpperCamelCase ()					->				None:
 A__							:   Tuple					       =		int(input("""Enter the order of the encryption key: """ ) )
 A__							:   int					       =		[]

 print("""Enter each row of the encryption key with space separated integers""" )
 for _ in range(lowercase_ ):
  A__							:   Union[str, Any]					       =		[int(lowercase_ ) for x in input().split()]
  hill_matrix.append(lowercase_ )

 A__							:   str					       =		HillCipher(numpy.array(lowercase_ ) )

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


if __name__ == "__main__":
 import doctest

 doctest.testmod()

 main()






from typing import TYPE_CHECKING

from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available
from ...utils import OptionalDependencyNotAvailable


A_	:			List[Any]  	=      {'configuration_gpt_neox': ['GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GPTNeoXConfig']}

try:
	if not is_tokenizers_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	A_	:			Optional[Any]  	=      ['GPTNeoXTokenizerFast']

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	A_	:			Optional[int]  	=      [
	    'GPT_NEOX_PRETRAINED_MODEL_ARCHIVE_LIST',
	    'GPTNeoXForCausalLM',
	    'GPTNeoXForQuestionAnswering',
	    'GPTNeoXForSequenceClassification',
	    'GPTNeoXForTokenClassification',
	    'GPTNeoXLayer',
	    'GPTNeoXModel',
	    'GPTNeoXPreTrainedModel',
	]


if TYPE_CHECKING:
	from .configuration_gpt_neox import GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP, GPTNeoXConfig

	try:
		if not is_tokenizers_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .tokenization_gpt_neox_fast import GPTNeoXTokenizerFast

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_gpt_neox import (
		    GPT_NEOX_PRETRAINED_MODEL_ARCHIVE_LIST,
		    GPTNeoXForCausalLM,
		    GPTNeoXForQuestionAnswering,
		    GPTNeoXForSequenceClassification,
		    GPTNeoXForTokenClassification,
		    GPTNeoXLayer,
		    GPTNeoXModel,
		    GPTNeoXPreTrainedModel,
		)


else:
	import sys

	A_	:			Any  	=      _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)



