




from collections import OrderedDict
from typing import TYPE_CHECKING, Any, Mapping, Optional, Union

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast
from ...utils import logging


if TYPE_CHECKING:
							from ...feature_extraction_utils import FeatureExtractionMixin
							from ...tokenization_utils_base import PreTrainedTokenizerBase
							from ...utils import TensorType

snake_case_						:			List[Any]													=							logging.get_logger(__name__)

snake_case_						:			Optional[int]													=							{
    '''openai/whisper-base''': '''https://huggingface.co/openai/whisper-base/resolve/main/config.json''',
}

# fmt: off
snake_case_						:			Optional[Any]													=							[
    1, 2, 7, 8, 9, 10, 14, 25,
    26, 27, 28, 29, 31, 58, 59, 60, 61, 62,
    63, 90, 91, 92, 93, 3_57, 3_66, 4_38, 5_32, 6_85,
    7_05, 7_96, 9_30, 10_58, 12_20, 12_67, 12_79, 13_03, 13_43, 13_77,
    13_91, 16_35, 17_82, 18_75, 21_62, 23_61, 24_88, 34_67, 40_08, 42_11,
    46_00, 48_08, 52_99, 58_55, 63_29, 72_03, 96_09, 99_59, 1_05_63, 1_07_86,
    1_14_20, 1_17_09, 1_19_07, 1_31_63, 1_36_97, 1_37_00, 1_48_08, 1_53_06, 1_64_10, 1_67_91,
    1_79_92, 1_92_03, 1_95_10, 2_07_24, 2_23_05, 2_29_35, 2_70_07, 3_01_09, 3_04_20, 3_34_09,
    3_49_49, 4_02_83, 4_04_93, 4_05_49, 4_72_82, 4_91_46, 5_02_57, 5_03_59, 5_03_60, 5_03_61
]
snake_case_						:			Union[str, Any]													=							[
    1, 2, 7, 8, 9, 10, 14, 25,
    26, 27, 28, 29, 31, 58, 59, 60, 61, 62,
    63, 90, 91, 92, 93, 3_59, 5_03, 5_22, 5_42, 8_73,
    8_93, 9_02, 9_18, 9_22, 9_31, 13_50, 18_53, 19_82, 24_60, 26_27,
    32_46, 32_53, 32_68, 35_36, 38_46, 39_61, 41_83, 46_67, 65_85, 66_47,
    72_73, 90_61, 93_83, 1_04_28, 1_09_29, 1_19_38, 1_20_33, 1_23_31, 1_25_62, 1_37_93,
    1_41_57, 1_46_35, 1_52_65, 1_56_18, 1_65_53, 1_66_04, 1_83_62, 1_89_56, 2_00_75, 2_16_75,
    2_25_20, 2_61_30, 2_61_61, 2_64_35, 2_82_79, 2_94_64, 3_16_50, 3_23_02, 3_24_70, 3_68_65,
    4_28_63, 4_74_25, 4_98_70, 5_02_54, 5_02_58, 5_03_60, 5_03_61, 5_03_62
]

class 						A__							(		UpperCamelCase__  ):
						UpperCAmelCase             =						"whisper"
						UpperCAmelCase             =						["past_key_values"]
						UpperCAmelCase             =						{"num_attention_heads": "encoder_attention_heads", "hidden_size": "d_model"}




						def __init__(       self					:      List[str]				,    _a					:      Dict=5_1865				,    _a					:      Tuple=80				,    _a					:      Dict=6				,    _a					:      Any=4				,    _a					:      int=6				,    _a					:      Union[str, Any]=4				,    _a					:      Tuple=1536				,    _a					:      List[Any]=1536				,    _a					:      List[Any]=0.0				,    _a					:      Any=0.0				,    _a					:      Optional[int]=5_0257				,    _a					:      List[str]=True				,    _a					:      List[str]=True				,    _a					:      Any="gelu"				,    _a					:      Optional[int]=256				,    _a					:      Union[str, Any]=0.0				,    _a					:      str=0.0				,    _a					:      List[str]=0.0				,    _a					:      Optional[Any]=0.02				,    _a					:      Any=False				,    _a					:      Tuple=1500				,    _a					:      Any=448				,    _a					:      Optional[int]=5_0256				,    _a					:      int=5_0256				,    _a					:      List[str]=5_0256				,    _a					:      List[str]=None				,    _a					:      Union[str, Any]=[220, 5_0256]				,    _a					:      Tuple=False				,    _a					:      Optional[Any]=256				,    _a					:      Optional[int]=False				,    _a					:      Optional[Any]=0.05				,    _a					:      Tuple=10				,    _a					:      str=2				,    _a					:      int=0.0				,    _a					:      List[Any]=10				,    _a					:      Tuple=0				,    _a					:      int=7				,    **_a					:      Any				,    )							->     Tuple:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =vocab_size
										_SCREAMING_SNAKE_CASE			  =num_mel_bins
										_SCREAMING_SNAKE_CASE			  =d_model
										_SCREAMING_SNAKE_CASE			  =encoder_layers
										_SCREAMING_SNAKE_CASE			  =encoder_attention_heads
										_SCREAMING_SNAKE_CASE			  =decoder_layers
										_SCREAMING_SNAKE_CASE			  =decoder_attention_heads
										_SCREAMING_SNAKE_CASE			  =decoder_ffn_dim
										_SCREAMING_SNAKE_CASE			  =encoder_ffn_dim
										_SCREAMING_SNAKE_CASE			  =dropout
										_SCREAMING_SNAKE_CASE			  =attention_dropout
										_SCREAMING_SNAKE_CASE			  =activation_dropout
										_SCREAMING_SNAKE_CASE			  =activation_function
										_SCREAMING_SNAKE_CASE			  =init_std
										_SCREAMING_SNAKE_CASE			  =encoder_layerdrop
										_SCREAMING_SNAKE_CASE			  =decoder_layerdrop
										_SCREAMING_SNAKE_CASE			  =use_cache
										_SCREAMING_SNAKE_CASE			  =encoder_layers
										_SCREAMING_SNAKE_CASE			  =scale_embedding  # scale factor will be sqrt(d_model) if True
										_SCREAMING_SNAKE_CASE			  =max_source_positions
										_SCREAMING_SNAKE_CASE			  =max_target_positions

										# Audio Classification-specific parameters. Feel free to ignore for other classes.
										_SCREAMING_SNAKE_CASE			  =classifier_proj_size
										_SCREAMING_SNAKE_CASE			  =use_weighted_layer_sum

										# fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
										_SCREAMING_SNAKE_CASE			  =apply_spec_augment
										_SCREAMING_SNAKE_CASE			  =mask_time_prob
										_SCREAMING_SNAKE_CASE			  =mask_time_length
										_SCREAMING_SNAKE_CASE			  =mask_time_min_masks
										_SCREAMING_SNAKE_CASE			  =mask_feature_prob
										_SCREAMING_SNAKE_CASE			  =mask_feature_length
										_SCREAMING_SNAKE_CASE			  =mask_feature_min_masks

										_SCREAMING_SNAKE_CASE			  =median_filter_width

										super().__init__(
										    pad_token_id=_a				,    bos_token_id=_a				,    eos_token_id=_a				,    is_encoder_decoder=_a				,    decoder_start_token_id=_a				,    suppress_tokens=_a				,    begin_suppress_tokens=_a				,    **_a				,    )

class 						A__							(		UpperCamelCase__  ):




						@property
						def 							__UpperCamelCase				(       self					:      Optional[Any]  )							->     Mapping[str, Mapping[int, str]]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =OrderedDict(
										    [
										        ('''input_features''', {0: '''batch''', 1: '''feature_size''', 2: '''encoder_sequence'''}),
										    ]  )
										if self.use_past:
														_SCREAMING_SNAKE_CASE			  ={0: '''batch'''}
										else:
														_SCREAMING_SNAKE_CASE			  ={0: '''batch''', 1: '''decoder_sequence'''}

										if self.use_past:
														self.fill_with_past_key_values_(_a				,    direction='''inputs'''  )

										return common_inputs




						def 							__UpperCamelCase				(       self					:      List[str]				,    _a					:      Union["PreTrainedTokenizerBase", "FeatureExtractionMixin"]				,    _a					:      int = -1				,    _a					:      int = -1				,    _a					:      bool = False				,    _a					:      Optional["TensorType"] = None				,    _a					:      int = 2_2050				,    _a					:      float = 5.0				,    _a					:      int = 220				,    )							->     Mapping[str, Any]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =OrderedDict()
										_SCREAMING_SNAKE_CASE			  =OnnxConfig.generate_dummy_inputs(
										    self				,    preprocessor=preprocessor.feature_extractor				,    batch_size=_a				,    framework=_a				,    sampling_rate=_a				,    time_duration=_a				,    frequency=_a				,    )
										_SCREAMING_SNAKE_CASE			  =encoder_inputs['''input_features'''].shape[2]
										_SCREAMING_SNAKE_CASE			  =encoder_sequence_length // 2 if self.use_past else seq_length

										_SCREAMING_SNAKE_CASE			  =super().generate_dummy_inputs(
										    preprocessor.tokenizer				,    _a				,    _a				,    _a				,    _a  )

										_SCREAMING_SNAKE_CASE			  =encoder_inputs.pop('''input_features'''  )
										_SCREAMING_SNAKE_CASE			  =decoder_inputs.pop('''decoder_input_ids'''  )

										if "past_key_values" in decoder_inputs:
														_SCREAMING_SNAKE_CASE			  =decoder_inputs.pop('''past_key_values'''  )

										return dummy_inputs




						@property
						def 							__UpperCamelCase				(       self					:      Union[str, Any]  )							->     float:


										"""simple docstring"""





										return 1E-3



import string

import numpy







def 						lowerCamelCase(   a__	,a__):
				return b if a == 0 else greatest_common_divisor(b % a	,a__)

class 						A__							:
						UpperCAmelCase             =						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             =						numpy.vectorize(lambda UpperCamelCase__  : x % 36  )

						UpperCAmelCase             =						numpy.vectorize(UpperCamelCase__  )




						def __init__(       self					:      int				,    _a					:      numpy.ndarray  )							->     None:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =self.modulus(_a  )  # mod36 calc's on the encrypt key
										self.check_determinant()  # validate the determinant of the encryption key
										_SCREAMING_SNAKE_CASE			  =encrypt_key.shape[0]




						def 							__UpperCamelCase				(       self					:      Dict				,    _a					:      str  )							->     int:


										"""simple docstring"""





										return self.key_string.index(_a  )




						def 							__UpperCamelCase				(       self					:      List[str]				,    _a					:      int  )							->     str:


										"""simple docstring"""





										return self.key_string[round(_a  )]




						def 							__UpperCamelCase				(       self					:      int  )							->     None:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =round(numpy.linalg.det(self.encrypt_key  )  )

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

										_SCREAMING_SNAKE_CASE			  =len(self.key_string  )
										if greatest_common_divisor(_a				,    len(self.key_string  )  ) != 1:
														_SCREAMING_SNAKE_CASE			  =(
														    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 							__UpperCamelCase				(       self					:      List[str]				,    _a					:      str  )							->     str:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =[char for char in text.upper() if char in self.key_string]

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

										return "".join(_a  )




						def 							__UpperCamelCase				(       self					:      List[str]				,    _a					:      str  )							->     str:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =self.process_text(text.upper()  )
										_SCREAMING_SNAKE_CASE			  =''''''

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

										return encrypted




						def 							__UpperCamelCase				(       self					:      Union[str, Any]  )							->     numpy.ndarray:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =round(numpy.linalg.det(self.encrypt_key  )  )

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

										_SCREAMING_SNAKE_CASE			  =(
										    det_inv
										    * numpy.linalg.det(self.encrypt_key  )
										    * numpy.linalg.inv(self.encrypt_key  )
										)

										return self.to_int(self.modulus(_a  )  )




						def 							__UpperCamelCase				(       self					:      str				,    _a					:      str  )							->     str:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =self.make_decrypt_key()
										_SCREAMING_SNAKE_CASE			  =self.process_text(text.upper()  )
										_SCREAMING_SNAKE_CASE			  =''''''

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

										return decrypted







def 						lowerCamelCase(   ):
				_SCREAMING_SNAKE_CASE			  =int(input('''Enter the order of the encryption key: '''))
				_SCREAMING_SNAKE_CASE			  =[]

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

				_SCREAMING_SNAKE_CASE			  =HillCipher(numpy.array(a__))

				print('''Would you like to encrypt or decrypt some text? (1 or 2)''')
				_SCREAMING_SNAKE_CASE			  =input('''\n1. Encrypt\n2. Decrypt\n''')
				if option == "1":
								_SCREAMING_SNAKE_CASE			  =input('''What text would you like to encrypt?: ''')
								print('''Your encrypted text is:''')
								print(hc.encrypt(a__))
				elif option == "2":
								_SCREAMING_SNAKE_CASE			  =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()