



'''simple docstring'''




import string

import numpy


def        lowerCAmelCase_     (			_lowerCamelCase:     int ,   _lowerCamelCase:     int      ):
		return b if a == 0 else greatest_common_divisor(b % a ,   _lowerCamelCase      )






class 		_UpperCamelCase						:


			'''simple docstring'''

			_A   :	Union[str, 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)
			_A   :	Union[str, Any]    					=	numpy.vectorize(lambda lowerCamelCase__					: x % 36					)

			_A   :	str    					=	numpy.vectorize(lowerCamelCase__					)

			def __init__(							self  :				Any							,  lowerCAmelCase__  :				numpy.ndarray		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	Tuple					 =	self.modulus(lowerCAmelCase__		)  # mod36 calc's on the encrypt key
					self.check_determinant()  # validate the determinant of the encryption key
					__SCREAMING_SNAKE_CASE :	List[str]					 =	encrypt_key.shape[0]

			def UpperCamelCase__      (							self  :				Any							,  lowerCAmelCase__  :				str		):





					"""simple docstring"""






					return self.key_string.index(lowerCAmelCase__		)

			def UpperCamelCase__      (							self  :				str							,  lowerCAmelCase__  :				int		):





					"""simple docstring"""






					return self.key_string[round(lowerCAmelCase__		)]

			def UpperCamelCase__      (							self  :				int		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	round(numpy.linalg.det(self.encrypt_key		)		)

					if det < 0:
							__SCREAMING_SNAKE_CASE :	Tuple					 =	det % len(self.key_string		)

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

			def UpperCamelCase__      (							self  :				Any							,  lowerCAmelCase__  :				str		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	Union[str, Any]					 =	[char for char in text.upper() if char in self.key_string]

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

					return "".join(lowerCAmelCase__		)

			def UpperCamelCase__      (							self  :				Any							,  lowerCAmelCase__  :				str		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	Dict					 =	self.process_text(text.upper()		)
					__SCREAMING_SNAKE_CASE :	Any					 =	""""""

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

					return encrypted

			def UpperCamelCase__      (							self  :				Optional[Any]		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	Union[str, Any]					 =	round(numpy.linalg.det(self.encrypt_key		)		)

					if det < 0:
							__SCREAMING_SNAKE_CASE :	Dict					 =	det % len(self.key_string		)
					__SCREAMING_SNAKE_CASE :	Tuple					 =	None
					for i in range(len(self.key_string		)		):
							if (det * i) % len(self.key_string		) == 1:
									__SCREAMING_SNAKE_CASE :	Dict					 =	i
									break

					__SCREAMING_SNAKE_CASE :	int					 =	(
					    det_inv
					    * numpy.linalg.det(self.encrypt_key		)
					    * numpy.linalg.inv(self.encrypt_key		)
					)

					return self.to_int(self.modulus(lowerCAmelCase__		)		)



			def UpperCamelCase__      (							self  :				Optional[int]							,  lowerCAmelCase__  :				str		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	int					 =	self.make_decrypt_key()
					__SCREAMING_SNAKE_CASE :	List[str]					 =	self.process_text(text.upper()		)
					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	""""""

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

					return decrypted


def        lowerCAmelCase_     (			):
		__SCREAMING_SNAKE_CASE :	List[str]					 =	int(input("""Enter the order of the encryption key: """      )      )
		__SCREAMING_SNAKE_CASE :	List[Any]					 =	[]

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

		__SCREAMING_SNAKE_CASE :	List[Any]					 =	HillCipher(numpy.array(_lowerCamelCase      )      )

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


if __name__ == "__main__":
						import doctest

						doctest.testmod()

						main()








'''simple docstring'''




import warnings

from ...utils import logging
from .image_processing_deit import DeiTImageProcessor


UpperCamelCase__ :			List[str]												=				logging.get_logger(__name__)






class 		_UpperCamelCase						(							lowerCamelCase__					):


			'''simple docstring'''

			def __init__(							self  :				Union[str, Any]							,  *lowerCAmelCase__  :				str							,  **lowerCAmelCase__  :				Any		):





					"""simple docstring"""






					warnings.warn(
					    """The class DeiTFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please"""
					    """ use DeiTImageProcessor instead."""							,  lowerCAmelCase__							,  )
					super().__init__(*lowerCAmelCase__							,  **lowerCAmelCase__		)