





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


lowercase_			       =				50_358
lowercase_			       =				50_362


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

    '''simple docstring'''


    def     snake_case_(	self )	->     int:
        _SCREAMING_SNAKE_CASE             =    """openai/whisper-small.en"""
        _SCREAMING_SNAKE_CASE             =    tempfile.mkdtemp()


    def     snake_case_(	self				,	**A )	->     Any:
        return WhisperTokenizer.from_pretrained(self.checkpoint				,	**A )


    def     snake_case_(	self				,	**A )	->     List[str]:
        return WhisperFeatureExtractor.from_pretrained(self.checkpoint				,	**A )


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


    def     snake_case_(	self )	->     Tuple:
        _SCREAMING_SNAKE_CASE             =    self.get_tokenizer()
        _SCREAMING_SNAKE_CASE             =    self.get_feature_extractor()

        _SCREAMING_SNAKE_CASE             =    WhisperProcessor(tokenizer=A				,	feature_extractor=A )

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

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

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


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

        _SCREAMING_SNAKE_CASE             =    self.get_tokenizer(bos_token="""(BOS)"""				,	eos_token="""(EOS)""" )
        _SCREAMING_SNAKE_CASE             =    self.get_feature_extractor(do_normalize=A				,	padding_value=1.0 )

        _SCREAMING_SNAKE_CASE             =    WhisperProcessor.from_pretrained(
            self.tmpdirname				,	bos_token="""(BOS)"""				,	eos_token="""(EOS)"""				,	do_normalize=A				,	padding_value=1.0 )

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

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


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

        _SCREAMING_SNAKE_CASE             =    WhisperProcessor(tokenizer=A				,	feature_extractor=A )

        _SCREAMING_SNAKE_CASE             =    floats_list((3, 1000) )

        _SCREAMING_SNAKE_CASE             =    feature_extractor(A				,	return_tensors="""np""" )
        _SCREAMING_SNAKE_CASE             =    processor(A				,	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 )	->     List[str]:
        _SCREAMING_SNAKE_CASE             =    self.get_feature_extractor()
        _SCREAMING_SNAKE_CASE             =    self.get_tokenizer()

        _SCREAMING_SNAKE_CASE             =    WhisperProcessor(tokenizer=A				,	feature_extractor=A )

        _SCREAMING_SNAKE_CASE             =    """This is a test string"""

        _SCREAMING_SNAKE_CASE             =    processor(text=A )

        _SCREAMING_SNAKE_CASE             =    tokenizer(A )

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


    def     snake_case_(	self )	->     Tuple:
        _SCREAMING_SNAKE_CASE             =    self.get_feature_extractor()
        _SCREAMING_SNAKE_CASE             =    self.get_tokenizer()

        _SCREAMING_SNAKE_CASE             =    WhisperProcessor(tokenizer=A				,	feature_extractor=A )

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

        _SCREAMING_SNAKE_CASE             =    processor.batch_decode(A )
        _SCREAMING_SNAKE_CASE             =    tokenizer.batch_decode(A )

        self.assertListEqual(A				,	A )


    def     snake_case_(	self )	->     Optional[Any]:
        _SCREAMING_SNAKE_CASE             =    self.get_feature_extractor()
        _SCREAMING_SNAKE_CASE             =    self.get_tokenizer()

        _SCREAMING_SNAKE_CASE             =    WhisperProcessor(tokenizer=A				,	feature_extractor=A )

        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 )	->     Optional[int]:
        _SCREAMING_SNAKE_CASE             =    self.get_feature_extractor()
        _SCREAMING_SNAKE_CASE             =    self.get_tokenizer()

        _SCREAMING_SNAKE_CASE             =    WhisperProcessor(tokenizer=A				,	feature_extractor=A )
        _SCREAMING_SNAKE_CASE             =    processor.get_decoder_prompt_ids(task="""transcribe"""				,	no_timestamps=A )

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

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


    def     snake_case_(	self )	->     Dict:
        _SCREAMING_SNAKE_CASE             =    WhisperProcessor(tokenizer=self.get_tokenizer()				,	feature_extractor=self.get_feature_extractor() )
        _SCREAMING_SNAKE_CASE             =    processor.get_prompt_ids("""Mr. Quilter""" )
        _SCREAMING_SNAKE_CASE             =    processor.tokenizer.decode(A )

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


    def     snake_case_(	self )	->     Tuple:
        _SCREAMING_SNAKE_CASE             =    WhisperProcessor(tokenizer=self.get_tokenizer()				,	feature_extractor=self.get_feature_extractor() )
        _SCREAMING_SNAKE_CASE             =    processor.get_prompt_ids("""""" )
        _SCREAMING_SNAKE_CASE             =    processor.tokenizer.decode(A )

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





    def     snake_case_(	self )	->     Dict:
        _SCREAMING_SNAKE_CASE             =    WhisperProcessor(tokenizer=self.get_tokenizer()				,	feature_extractor=self.get_feature_extractor() )

        def _test_prompt_error_raised_helper(A				,	A ):
            with pytest.raises(A ) as excinfo:
                processor.get_prompt_ids(A )
            _SCREAMING_SNAKE_CASE             =    f'Encountered text in the prompt corresponding to disallowed special token: {special_token}.'
            self.assertEqual(A				,	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		(  __lowerCamelCase				:					int = 10**6					)		->int:

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

    _SCREAMING_SNAKE_CASE             =    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      , __lowerCamelCase					):
                _SCREAMING_SNAKE_CASE             =    (phi[multiple] // number) * (number - 1)

    _SCREAMING_SNAKE_CASE             =    1
    for number in range(1      , n + 1					):
        if (answer / phi[answer]) < (number / phi[number]):
            _SCREAMING_SNAKE_CASE             =    number

    return answer


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



