





"""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


lowerCamelCase_          =	5_0_3_5_8
lowerCamelCase_          =	5_0_3_6_2






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




							def 					_UpperCamelCase  (		self							)    ->   Optional[Any]:





													"""simple docstring"""






													__SCREAMING_SNAKE_CASE     :Dict	       =						'''openai/whisper-small.en'''
													__SCREAMING_SNAKE_CASE     :List[Any]	       =						tempfile.mkdtemp()




							def 					_UpperCamelCase  (		self	,**SCREAMING_SNAKE_CASE__							)    ->   Dict:





													"""simple docstring"""






													return WhisperTokenizer.from_pretrained(self.checkpoint	,**SCREAMING_SNAKE_CASE__							)




							def 					_UpperCamelCase  (		self	,**SCREAMING_SNAKE_CASE__							)    ->   int:





													"""simple docstring"""






													return WhisperFeatureExtractor.from_pretrained(self.checkpoint	,**SCREAMING_SNAKE_CASE__							)




							def 					_UpperCamelCase  (		self							)    ->   Any:





													"""simple docstring"""






													shutil.rmtree(self.tmpdirname							)




							def 					_UpperCamelCase  (		self							)    ->   int:





													"""simple docstring"""






													__SCREAMING_SNAKE_CASE     :str	       =						self.get_tokenizer()
													__SCREAMING_SNAKE_CASE     :List[str]	       =						self.get_feature_extractor()

													__SCREAMING_SNAKE_CASE     :Dict	       =						WhisperProcessor(tokenizer=SCREAMING_SNAKE_CASE__	,feature_extractor=SCREAMING_SNAKE_CASE__							)

													processor.save_pretrained(self.tmpdirname							)
													__SCREAMING_SNAKE_CASE     :Union[str, Any]	       =						WhisperProcessor.from_pretrained(self.tmpdirname							)

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

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




							def 					_UpperCamelCase  (		self							)    ->   List[str]:





													"""simple docstring"""






													__SCREAMING_SNAKE_CASE     :List[str]	       =						WhisperProcessor(tokenizer=self.get_tokenizer()	,feature_extractor=self.get_feature_extractor()							)
													processor.save_pretrained(self.tmpdirname							)

													__SCREAMING_SNAKE_CASE     :Optional[int]	       =						self.get_tokenizer(bos_token='''(BOS)'''	,eos_token='''(EOS)'''							)
													__SCREAMING_SNAKE_CASE     :List[Any]	       =						self.get_feature_extractor(do_normalize=SCREAMING_SNAKE_CASE__	,padding_value=1.0							)

													__SCREAMING_SNAKE_CASE     :Dict	       =						WhisperProcessor.from_pretrained(
													    self.tmpdirname	,bos_token='''(BOS)'''	,eos_token='''(EOS)'''	,do_normalize=SCREAMING_SNAKE_CASE__	,padding_value=1.0							)

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

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




							def 					_UpperCamelCase  (		self							)    ->   List[Any]:





													"""simple docstring"""






													__SCREAMING_SNAKE_CASE     :List[str]	       =						self.get_feature_extractor()
													__SCREAMING_SNAKE_CASE     :List[Any]	       =						self.get_tokenizer()

													__SCREAMING_SNAKE_CASE     :Optional[Any]	       =						WhisperProcessor(tokenizer=SCREAMING_SNAKE_CASE__	,feature_extractor=SCREAMING_SNAKE_CASE__							)

													__SCREAMING_SNAKE_CASE     :str	       =						floats_list((3, 10_00)							)

													__SCREAMING_SNAKE_CASE     :Dict	       =						feature_extractor(SCREAMING_SNAKE_CASE__	,return_tensors='''np'''							)
													__SCREAMING_SNAKE_CASE     :Any	       =						processor(SCREAMING_SNAKE_CASE__	,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 					_UpperCamelCase  (		self							)    ->   Optional[Any]:





													"""simple docstring"""






													__SCREAMING_SNAKE_CASE     :List[Any]	       =						self.get_feature_extractor()
													__SCREAMING_SNAKE_CASE     :Union[str, Any]	       =						self.get_tokenizer()

													__SCREAMING_SNAKE_CASE     :int	       =						WhisperProcessor(tokenizer=SCREAMING_SNAKE_CASE__	,feature_extractor=SCREAMING_SNAKE_CASE__							)

													__SCREAMING_SNAKE_CASE     :List[Any]	       =						'''This is a test string'''

													__SCREAMING_SNAKE_CASE     :Any	       =						processor(text=SCREAMING_SNAKE_CASE__							)

													__SCREAMING_SNAKE_CASE     :Optional[int]	       =						tokenizer(SCREAMING_SNAKE_CASE__							)

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




							def 					_UpperCamelCase  (		self							)    ->   Optional[int]:





													"""simple docstring"""






													__SCREAMING_SNAKE_CASE     :Union[str, Any]	       =						self.get_feature_extractor()
													__SCREAMING_SNAKE_CASE     :str	       =						self.get_tokenizer()

													__SCREAMING_SNAKE_CASE     :List[Any]	       =						WhisperProcessor(tokenizer=SCREAMING_SNAKE_CASE__	,feature_extractor=SCREAMING_SNAKE_CASE__							)

													__SCREAMING_SNAKE_CASE     :str	       =						[[1, 4, 5, 8, 1, 0, 8], [3, 4, 3, 1, 1, 8, 9]]

													__SCREAMING_SNAKE_CASE     :Optional[int]	       =						processor.batch_decode(SCREAMING_SNAKE_CASE__							)
													__SCREAMING_SNAKE_CASE     :List[Any]	       =						tokenizer.batch_decode(SCREAMING_SNAKE_CASE__							)

													self.assertListEqual(SCREAMING_SNAKE_CASE__	,SCREAMING_SNAKE_CASE__							)




							def 					_UpperCamelCase  (		self							)    ->   Any:





													"""simple docstring"""






													__SCREAMING_SNAKE_CASE     :Any	       =						self.get_feature_extractor()
													__SCREAMING_SNAKE_CASE     :str	       =						self.get_tokenizer()

													__SCREAMING_SNAKE_CASE     :Optional[int]	       =						WhisperProcessor(tokenizer=SCREAMING_SNAKE_CASE__	,feature_extractor=SCREAMING_SNAKE_CASE__							)

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




							def 					_UpperCamelCase  (		self							)    ->   Optional[Any]:





													"""simple docstring"""






													__SCREAMING_SNAKE_CASE     :List[Any]	       =						self.get_feature_extractor()
													__SCREAMING_SNAKE_CASE     :str	       =						self.get_tokenizer()

													__SCREAMING_SNAKE_CASE     :Any	       =						WhisperProcessor(tokenizer=SCREAMING_SNAKE_CASE__	,feature_extractor=SCREAMING_SNAKE_CASE__							)
													__SCREAMING_SNAKE_CASE     :Any	       =						processor.get_decoder_prompt_ids(task='''transcribe'''	,no_timestamps=SCREAMING_SNAKE_CASE__							)

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

													__SCREAMING_SNAKE_CASE     :Union[str, Any]	       =						[TRANSCRIBE, NOTIMESTAMPS]
													self.assertListEqual([ids[-1] for ids in forced_decoder_ids]	,SCREAMING_SNAKE_CASE__							)




							def 					_UpperCamelCase  (		self							)    ->   Optional[int]:





													"""simple docstring"""






													__SCREAMING_SNAKE_CASE     :Dict	       =						WhisperProcessor(tokenizer=self.get_tokenizer()	,feature_extractor=self.get_feature_extractor()							)
													__SCREAMING_SNAKE_CASE     :Dict	       =						processor.get_prompt_ids('''Mr. Quilter'''							)
													__SCREAMING_SNAKE_CASE     :List[Any]	       =						processor.tokenizer.decode(SCREAMING_SNAKE_CASE__							)

													self.assertListEqual(prompt_ids.tolist()	,[5_03_60, 17_70, 13, 22_64, 3_46, 3_53]							)
													self.assertEqual(SCREAMING_SNAKE_CASE__	,'''<|startofprev|> Mr. Quilter'''							)




							def 					_UpperCamelCase  (		self							)    ->   Optional[int]:





													"""simple docstring"""






													__SCREAMING_SNAKE_CASE     :str	       =						WhisperProcessor(tokenizer=self.get_tokenizer()	,feature_extractor=self.get_feature_extractor()							)
													__SCREAMING_SNAKE_CASE     :List[str]	       =						processor.get_prompt_ids(''''''							)
													__SCREAMING_SNAKE_CASE     :int	       =						processor.tokenizer.decode(SCREAMING_SNAKE_CASE__							)

													self.assertListEqual(prompt_ids.tolist()	,[5_03_60, 2_20]							)
													self.assertEqual(SCREAMING_SNAKE_CASE__	,'''<|startofprev|> '''							)




							def 					_UpperCamelCase  (		self							)    ->   Any:





													"""simple docstring"""






													__SCREAMING_SNAKE_CASE     :Any	       =						WhisperProcessor(tokenizer=self.get_tokenizer()	,feature_extractor=self.get_feature_extractor()							)

													def _test_prompt_error_raised_helper(SCREAMING_SNAKE_CASE__	,SCREAMING_SNAKE_CASE__							):
																			with pytest.raises(SCREAMING_SNAKE_CASE__							) as excinfo:
																									processor.get_prompt_ids(SCREAMING_SNAKE_CASE__							)
																			__SCREAMING_SNAKE_CASE     :Optional[int]	       =						f'''Encountered text in the prompt corresponding to disallowed special token: {special_token}.'''
																			self.assertEqual(SCREAMING_SNAKE_CASE__	,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|>'''							)






"""simple docstring"""
def   __lowerCamelCase     (							a_  :	int = 10**6							)    ->   int:

      if n <= 0:
            raise ValueError('''Please enter an integer greater than 0'''							)

      __SCREAMING_SNAKE_CASE     :Tuple	       =						list(range(n + 1							)							)
      for number in range(2				,     n + 1							):
            if phi[number] == number:
                  phi[number] -= 1
                  for multiple in range(number * 2				,     n + 1				,     a_							):
                        __SCREAMING_SNAKE_CASE     :List[Any]	       =						(phi[multiple] // number) * (number - 1)

      __SCREAMING_SNAKE_CASE     :Optional[Any]	       =						1
      for number in range(1				,     n + 1							):
            if (answer / phi[answer]) < (number / phi[number]):
                  __SCREAMING_SNAKE_CASE     :str	       =						number

      return answer


if __name__ == "__main__":
  print(solution())