
'''simple docstring'''





from typing import List, Optional, Union

import numpy as np

from ...feature_extraction_sequence_utils import SequenceFeatureExtractor
from ...feature_extraction_utils import BatchFeature
from ...utils import PaddingStrategy, TensorType, logging


UpperCAmelCase            = logging.get_logger(__name__)

class     a (					__magic_name__     ):
				_snake_case		     =			['''input_values''', '''attention_mask''']




				def __init__(				self						:					List[str],     SCREAMING_SNAKE_CASE_						:					Union[str, Any]=1,     SCREAMING_SNAKE_CASE_						:					Optional[int]=1_60_00,     SCREAMING_SNAKE_CASE_						:					List[Any]=0.0,     SCREAMING_SNAKE_CASE_						:					List[Any]=False,     SCREAMING_SNAKE_CASE_						:					Union[str, Any]=True,     **SCREAMING_SNAKE_CASE_						:					Any,     ):
										super().__init__(feature_size=SCREAMING_SNAKE_CASE_,     sampling_rate=SCREAMING_SNAKE_CASE_,     padding_value=SCREAMING_SNAKE_CASE_,     **SCREAMING_SNAKE_CASE_   )
										snake_case							:  Any			=     return_attention_mask
										snake_case							:  List[str]			=     do_normalize




				@staticmethod
				def 						__snake_case				(				SCREAMING_SNAKE_CASE_						:					List[np.ndarray],     SCREAMING_SNAKE_CASE_						:					List[np.ndarray],     SCREAMING_SNAKE_CASE_						:					float = 0.0   ):
										if attention_mask is not None:
																snake_case							:  str			=     np.array(SCREAMING_SNAKE_CASE_,     np.intaa   )
																snake_case							:  int			=     []

																for vector, length in zip(SCREAMING_SNAKE_CASE_,     attention_mask.sum(-1   )   ):
																						snake_case							:  Dict			=     (vector - vector[:length].mean()) / np.sqrt(vector[:length].var() + 1e-7   )
																						if length < normed_slice.shape[0]:
																												snake_case							:  Any			=     padding_value

																						normed_input_values.append(SCREAMING_SNAKE_CASE_   )
										else:
																snake_case							:  Any			=     [(x - x.mean()) / np.sqrt(x.var() + 1e-7   ) for x in input_values]

										return normed_input_values




				def __call__(				self						:					List[str],     SCREAMING_SNAKE_CASE_						:					Union[np.ndarray, List[float], List[np.ndarray], List[List[float]]],     SCREAMING_SNAKE_CASE_						:					Union[bool, str, PaddingStrategy] = False,     SCREAMING_SNAKE_CASE_						:					Optional[int] = None,     SCREAMING_SNAKE_CASE_						:					bool = False,     SCREAMING_SNAKE_CASE_						:					Optional[int] = None,     SCREAMING_SNAKE_CASE_						:					Optional[bool] = None,     SCREAMING_SNAKE_CASE_						:					Optional[Union[str, TensorType]] = None,     SCREAMING_SNAKE_CASE_						:					Optional[int] = None,     **SCREAMING_SNAKE_CASE_						:					int,     ):

										if sampling_rate is not None:
																if sampling_rate != self.sampling_rate:
																						raise ValueError(
																						    F"""The model corresponding to this feature extractor: {self} was trained using a sampling rate of"""
																						    F""" {self.sampling_rate}. Please make sure that the provided `raw_speech` input was sampled with"""
																						    F""" {self.sampling_rate} and not {sampling_rate}."""   )
										else:
																logger.warning(
																    '''It is strongly recommended to pass the ``sampling_rate`` argument to this function. '''
																    '''Failing to do so can result in silent errors that might be hard to debug.'''   )

										snake_case							:  Optional[int]			=     isinstance(SCREAMING_SNAKE_CASE_,     np.ndarray   ) and len(raw_speech.shape   ) > 1
										if is_batched_numpy and len(raw_speech.shape   ) > 2:
																raise ValueError(F"""Only mono-channel audio is supported for input to {self}"""   )
										snake_case							:  Any			=     is_batched_numpy or (
										    isinstance(SCREAMING_SNAKE_CASE_,     (list, tuple)   ) and (isinstance(raw_speech[0],     (np.ndarray, tuple, list)   ))
										)

										# always return batch
										if not is_batched:
																snake_case							:  Optional[int]			=     [raw_speech]

										# convert into correct format for padding
										snake_case							:  Tuple			=     BatchFeature({'''input_values''': raw_speech}   )

										snake_case							:  Dict			=     self.pad(
										    SCREAMING_SNAKE_CASE_,     padding=SCREAMING_SNAKE_CASE_,     max_length=SCREAMING_SNAKE_CASE_,     truncation=SCREAMING_SNAKE_CASE_,     pad_to_multiple_of=SCREAMING_SNAKE_CASE_,     return_attention_mask=SCREAMING_SNAKE_CASE_,     )

										# convert input values to correct format
										snake_case							:  Tuple			=     padded_inputs['''input_values''']
										if not isinstance(input_values[0],     np.ndarray   ):
																snake_case							:  List[Any]			=     [np.asarray(SCREAMING_SNAKE_CASE_,     dtype=np.floataa   ) for array in input_values]
										elif (
										    not isinstance(SCREAMING_SNAKE_CASE_,     np.ndarray   )
										    and isinstance(input_values[0],     np.ndarray   )
										    and input_values[0].dtype is np.dtype(np.floataa   )
										):
																snake_case							:  int			=     [array.astype(np.floataa   ) for array in input_values]
										elif isinstance(SCREAMING_SNAKE_CASE_,     np.ndarray   ) and input_values.dtype is np.dtype(np.floataa   ):
																snake_case							:  Union[str, Any]			=     input_values.astype(np.floataa   )

										# convert attention_mask to correct format
										snake_case							:  List[str]			=     padded_inputs.get('''attention_mask'''   )
										if attention_mask is not None:
																snake_case							:  Tuple			=     [np.asarray(SCREAMING_SNAKE_CASE_,     dtype=np.intaa   ) for array in attention_mask]

										# zero-mean and unit-variance normalization
										if self.do_normalize:
																snake_case							:  int			=     (
																    attention_mask
																    if self._get_padding_strategies(SCREAMING_SNAKE_CASE_,     max_length=SCREAMING_SNAKE_CASE_   ) is not PaddingStrategy.DO_NOT_PAD
																    else None
																)
																snake_case							:  Optional[int]			=     self.zero_mean_unit_var_norm(
																    padded_inputs['''input_values'''],     attention_mask=SCREAMING_SNAKE_CASE_,     padding_value=self.padding_value   )

										if return_tensors is not None:
																snake_case							:  List[str]			=     padded_inputs.convert_to_tensors(SCREAMING_SNAKE_CASE_   )

										return padded_inputs









from __future__ import annotations

from string import ascii_letters

def 			__lowerCamelCase     (						snake_case__			,snake_case__			,snake_case__ = None						)				->    str:






						"""simple docstring"""





						_SCREAMING_SNAKE_CASE       =    alphabet or ascii_letters

						# The final result string
						_SCREAMING_SNAKE_CASE       =    """"""

						for character in input_string:
												if character not in alpha:
																		# Append without encryption if character is not in the alphabet
																		result += character
												else:
																		# Get the index of the new key and make sure it isn't too large
																		_SCREAMING_SNAKE_CASE       =    (alpha.index(snake_case__						) + key) % len(snake_case__						)

																		# Append the encoded character to the alphabet
																		result += alpha[new_key]

						return result

def 			__lowerCamelCase     (						snake_case__			,snake_case__			,snake_case__ = None						)				->    str:






						"""simple docstring"""





						key *= -1

						return encrypt(snake_case__			,snake_case__			,snake_case__						)

def 			__lowerCamelCase     (						snake_case__			,snake_case__ = None						)				->    dict[int, str]:






						"""simple docstring"""





						_SCREAMING_SNAKE_CASE       =    alphabet or ascii_letters

						# To store data on all the combinations
						_SCREAMING_SNAKE_CASE       =    {}

						# Cycle through each combination
						for key in range(1			,len(snake_case__						) + 1						):
												# Decrypt the message and store the result in the data
												_SCREAMING_SNAKE_CASE       =    decrypt(snake_case__			,snake_case__			,snake_case__						)

						return brute_force_data


if __name__ == "__main__":
		while True:
				print(f"\n{'-' * 10}\n Menu\n{'-' * 10}")
				print(*['''1.Encrypt''', '''2.Decrypt''', '''3.BruteForce''', '''4.Quit'''], sep='''\n''')

				# get user input
				UpperCamelCase												=      input('''\nWhat would you like to do?: ''').strip() or '''4'''

				# run functions based on what the user chose
				if choice not in ("1", "2", "3", "4"):
						print('''Invalid choice, please enter a valid choice''')
				elif choice == "1":
						UpperCamelCase												=      input('''Please enter the string to be encrypted: ''')
						UpperCamelCase												=      int(input('''Please enter off-set: ''').strip())

						print(encrypt(input_string, key))
				elif choice == "2":
						UpperCamelCase												=      input('''Please enter the string to be decrypted: ''')
						UpperCamelCase												=      int(input('''Please enter off-set: ''').strip())

						print(decrypt(input_string, key))
				elif choice == "3":
						UpperCamelCase												=      input('''Please enter the string to be decrypted: ''')
						UpperCamelCase												=      brute_force(input_string)

						for key, value in brute_force_data.items():
								print(f"Key: {key} | Message: {value}")

				elif choice == "4":
						print('''Goodbye.''')
						break

