


'''simple docstring'''




a__				: Dict									=    {
    '''A''': ('''ABCDEFGHIJKLM''', '''NOPQRSTUVWXYZ'''),
    '''B''': ('''ABCDEFGHIJKLM''', '''NOPQRSTUVWXYZ'''),
    '''C''': ('''ABCDEFGHIJKLM''', '''ZNOPQRSTUVWXY'''),
    '''D''': ('''ABCDEFGHIJKLM''', '''ZNOPQRSTUVWXY'''),
    '''E''': ('''ABCDEFGHIJKLM''', '''YZNOPQRSTUVWX'''),
    '''F''': ('''ABCDEFGHIJKLM''', '''YZNOPQRSTUVWX'''),
    '''G''': ('''ABCDEFGHIJKLM''', '''XYZNOPQRSTUVW'''),
    '''H''': ('''ABCDEFGHIJKLM''', '''XYZNOPQRSTUVW'''),
    '''I''': ('''ABCDEFGHIJKLM''', '''WXYZNOPQRSTUV'''),
    '''J''': ('''ABCDEFGHIJKLM''', '''WXYZNOPQRSTUV'''),
    '''K''': ('''ABCDEFGHIJKLM''', '''VWXYZNOPQRSTU'''),
    '''L''': ('''ABCDEFGHIJKLM''', '''VWXYZNOPQRSTU'''),
    '''M''': ('''ABCDEFGHIJKLM''', '''UVWXYZNOPQRST'''),
    '''N''': ('''ABCDEFGHIJKLM''', '''UVWXYZNOPQRST'''),
    '''O''': ('''ABCDEFGHIJKLM''', '''TUVWXYZNOPQRS'''),
    '''P''': ('''ABCDEFGHIJKLM''', '''TUVWXYZNOPQRS'''),
    '''Q''': ('''ABCDEFGHIJKLM''', '''STUVWXYZNOPQR'''),
    '''R''': ('''ABCDEFGHIJKLM''', '''STUVWXYZNOPQR'''),
    '''S''': ('''ABCDEFGHIJKLM''', '''RSTUVWXYZNOPQ'''),
    '''T''': ('''ABCDEFGHIJKLM''', '''RSTUVWXYZNOPQ'''),
    '''U''': ('''ABCDEFGHIJKLM''', '''QRSTUVWXYZNOP'''),
    '''V''': ('''ABCDEFGHIJKLM''', '''QRSTUVWXYZNOP'''),
    '''W''': ('''ABCDEFGHIJKLM''', '''PQRSTUVWXYZNO'''),
    '''X''': ('''ABCDEFGHIJKLM''', '''PQRSTUVWXYZNO'''),
    '''Y''': ('''ABCDEFGHIJKLM''', '''OPQRSTUVWXYZN'''),
    '''Z''': ('''ABCDEFGHIJKLM''', '''OPQRSTUVWXYZN'''),
}




def 	__lowerCamelCase (  UpperCAmelCase_       )      ->list[tuple[str, str]]:
	return [alphabet[char] for char in key.upper()]




def 	__lowerCamelCase (  UpperCAmelCase_				,							UpperCAmelCase_       )      ->str:
	snake_case__  					=      ''
	snake_case__  					=      0
	snake_case__  					=      generate_table(UpperCAmelCase_       )
	for char in words.upper():
		cipher += get_opponent(table[count]				,							UpperCAmelCase_       )
		snake_case__  					=      (count + 1) % len(UpperCAmelCase_       )
	return cipher




def 	__lowerCamelCase (  UpperCAmelCase_				,							UpperCAmelCase_       )      ->str:
	return encrypt(UpperCAmelCase_				,							UpperCAmelCase_       )




def 	__lowerCamelCase (  UpperCAmelCase_				,							UpperCAmelCase_       )      ->tuple[int, int]:
	snake_case__  					=      0 if char in table[0] else 1
	snake_case__  					=      table[row].index(UpperCAmelCase_       )
	return row, col




def 	__lowerCamelCase (  UpperCAmelCase_				,							UpperCAmelCase_       )      ->str:
	snake_case__					,     snake_case__  					=      get_position(UpperCAmelCase_				,							char.upper()       )
	if row == 1:
		return table[0][col]
	else:
		return table[1][col] if row == 0 else char


if __name__ == "__main__":
			import doctest

			doctest.testmod()  # Fist ensure that all our tests are passing...
			a__				: Optional[Any]									=    input('''Enter key: ''').strip()
			a__				: Optional[int]									=    input('''Enter text to encrypt: ''').strip()
			a__				: Optional[int]									=    encrypt(key, text)

			print(f"""Encrypted: {cipher_text}""")
			print(f"""Decrypted with key: {decrypt(key, cipher_text)}""")










'''simple docstring'''




import shutil
import tempfile
import unittest

import pytest

from transformers import WhisperTokenizer, is_speech_available
from transformers.testing_utils import require_sentencepiece, require_torch, require_torchaudio

from .test_feature_extraction_whisper import floats_list


if is_speech_available():
			from transformers import WhisperFeatureExtractor, WhisperProcessor


a__				: Tuple									=    5_0358
a__				: str									=    5_0362






@require_torch
@require_torchaudio
@require_sentencepiece
class 							__snake_case    (				unittest.TestCase       ):





	def      _snake_case      (		self		)			->		Dict:
		snake_case__  					=      'openai/whisper-small.en'
		snake_case__  					=      tempfile.mkdtemp()





	def      _snake_case      (		self			,					**UpperCamelCase_		)			->		Optional[int]:
		return WhisperTokenizer.from_pretrained(self.checkpoint			,					**UpperCamelCase_		)





	def      _snake_case      (		self			,					**UpperCamelCase_		)			->		Any:
		return WhisperFeatureExtractor.from_pretrained(self.checkpoint			,					**UpperCamelCase_		)





	def      _snake_case      (		self		)			->		Tuple:
		shutil.rmtree(self.tmpdirname		)





	def      _snake_case      (		self		)			->		Any:
		snake_case__  					=      self.get_tokenizer()
		snake_case__  					=      self.get_feature_extractor()

		snake_case__  					=      WhisperProcessor(tokenizer=UpperCamelCase_			,					feature_extractor=UpperCamelCase_		)

		processor.save_pretrained(self.tmpdirname		)
		snake_case__  					=      WhisperProcessor.from_pretrained(self.tmpdirname		)

		self.assertEqual(processor.tokenizer.get_vocab()			,					tokenizer.get_vocab()		)
		self.assertIsInstance(processor.tokenizer			,					UpperCamelCase_		)

		self.assertEqual(processor.feature_extractor.to_json_string()			,					feature_extractor.to_json_string()		)
		self.assertIsInstance(processor.feature_extractor			,					UpperCamelCase_		)





	def      _snake_case      (		self		)			->		Dict:
		snake_case__  					=      WhisperProcessor(tokenizer=self.get_tokenizer()			,					feature_extractor=self.get_feature_extractor()		)
		processor.save_pretrained(self.tmpdirname		)

		snake_case__  					=      self.get_tokenizer(bos_token='(BOS)'			,					eos_token='(EOS)'		)
		snake_case__  					=      self.get_feature_extractor(do_normalize=UpperCamelCase_			,					padding_value=1.0		)

		snake_case__  					=      WhisperProcessor.from_pretrained(
		    self.tmpdirname			,					bos_token='(BOS)'			,					eos_token='(EOS)'			,					do_normalize=UpperCamelCase_			,					padding_value=1.0		)

		self.assertEqual(processor.tokenizer.get_vocab()			,					tokenizer_add_kwargs.get_vocab()		)
		self.assertIsInstance(processor.tokenizer			,					UpperCamelCase_		)

		self.assertEqual(processor.feature_extractor.to_json_string()			,					feature_extractor_add_kwargs.to_json_string()		)
		self.assertIsInstance(processor.feature_extractor			,					UpperCamelCase_		)





	def      _snake_case      (		self		)			->		List[str]:
		snake_case__  					=      self.get_feature_extractor()
		snake_case__  					=      self.get_tokenizer()

		snake_case__  					=      WhisperProcessor(tokenizer=UpperCamelCase_			,					feature_extractor=UpperCamelCase_		)

		snake_case__  					=      floats_list((3, 1000)		)

		snake_case__  					=      feature_extractor(UpperCamelCase_			,					return_tensors='np'		)
		snake_case__  					=      processor(UpperCamelCase_			,					return_tensors='np'		)

		for key in input_feat_extract.keys():
			self.assertAlmostEqual(input_feat_extract[key].sum()			,					input_processor[key].sum()			,					delta=1E-2		)





	def      _snake_case      (		self		)			->		Union[str, Any]:
		snake_case__  					=      self.get_feature_extractor()
		snake_case__  					=      self.get_tokenizer()

		snake_case__  					=      WhisperProcessor(tokenizer=UpperCamelCase_			,					feature_extractor=UpperCamelCase_		)

		snake_case__  					=      'This is a test string'

		snake_case__  					=      processor(text=UpperCamelCase_		)

		snake_case__  					=      tokenizer(UpperCamelCase_		)

		for key in encoded_tok.keys():
			self.assertListEqual(encoded_tok[key]			,					encoded_processor[key]		)





	def      _snake_case      (		self		)			->		Tuple:
		snake_case__  					=      self.get_feature_extractor()
		snake_case__  					=      self.get_tokenizer()

		snake_case__  					=      WhisperProcessor(tokenizer=UpperCamelCase_			,					feature_extractor=UpperCamelCase_		)

		snake_case__  					=      [[1, 4, 5, 8, 1, 0, 8], [3, 4, 3, 1, 1, 8, 9]]

		snake_case__  					=      processor.batch_decode(UpperCamelCase_		)
		snake_case__  					=      tokenizer.batch_decode(UpperCamelCase_		)

		self.assertListEqual(UpperCamelCase_			,					UpperCamelCase_		)





	def      _snake_case      (		self		)			->		List[str]:
		snake_case__  					=      self.get_feature_extractor()
		snake_case__  					=      self.get_tokenizer()

		snake_case__  					=      WhisperProcessor(tokenizer=UpperCamelCase_			,					feature_extractor=UpperCamelCase_		)

		self.assertListEqual(
		    processor.model_input_names			,					feature_extractor.model_input_names			,					msg='`processor` and `feature_extractor` model input names do not match'			,					)





	def      _snake_case      (		self		)			->		Dict:
		snake_case__  					=      self.get_feature_extractor()
		snake_case__  					=      self.get_tokenizer()

		snake_case__  					=      WhisperProcessor(tokenizer=UpperCamelCase_			,					feature_extractor=UpperCamelCase_		)
		snake_case__  					=      processor.get_decoder_prompt_ids(task='transcribe'			,					no_timestamps=UpperCamelCase_		)

		self.assertIsInstance(UpperCamelCase_			,					UpperCamelCase_		)
		for ids in forced_decoder_ids:
			self.assertIsInstance(UpperCamelCase_			,					(list, tuple)		)

		snake_case__  					=      [TRANSCRIBE, NOTIMESTAMPS]
		self.assertListEqual([ids[-1] for ids in forced_decoder_ids]			,					UpperCamelCase_		)





	def      _snake_case      (		self		)			->		List[str]:
		snake_case__  					=      WhisperProcessor(tokenizer=self.get_tokenizer()			,					feature_extractor=self.get_feature_extractor()		)
		snake_case__  					=      processor.get_prompt_ids('Mr. Quilter'		)
		snake_case__  					=      processor.tokenizer.decode(UpperCamelCase_		)

		self.assertListEqual(prompt_ids.tolist()			,					[5_0360, 1770, 13, 2264, 346, 353]		)
		self.assertEqual(UpperCamelCase_			,					'<|startofprev|> Mr. Quilter'		)





	def      _snake_case      (		self		)			->		Dict:
		snake_case__  					=      WhisperProcessor(tokenizer=self.get_tokenizer()			,					feature_extractor=self.get_feature_extractor()		)
		snake_case__  					=      processor.get_prompt_ids(''		)
		snake_case__  					=      processor.tokenizer.decode(UpperCamelCase_		)

		self.assertListEqual(prompt_ids.tolist()			,					[5_0360, 220]		)
		self.assertEqual(UpperCamelCase_			,					'<|startofprev|> '		)





	def      _snake_case      (		self		)			->		int:
		snake_case__  					=      WhisperProcessor(tokenizer=self.get_tokenizer()			,					feature_extractor=self.get_feature_extractor()		)

		def _test_prompt_error_raised_helper(UpperCamelCase_			,					UpperCamelCase_		):
			with pytest.raises(UpperCamelCase_		) as excinfo:
				processor.get_prompt_ids(UpperCamelCase_		)
			snake_case__  					=      F'''Encountered text in the prompt corresponding to disallowed special token: {special_token}.'''
			self.assertEqual(UpperCamelCase_			,					str(excinfo.value		)		)

		_test_prompt_error_raised_helper('<|startofprev|> test'			,					'<|startofprev|>'		)
		_test_prompt_error_raised_helper('test <|notimestamps|>'			,					'<|notimestamps|>'		)
		_test_prompt_error_raised_helper('test <|zh|> test <|transcribe|>'			,					'<|zh|>'		)



