"""simple docstring"""
import json
import os
import shutil
import tempfile
import unittest

from transformers import is_speech_available, is_torch_available
from transformers.models.speechta import SpeechTaTokenizer
from transformers.testing_utils import get_tests_dir, require_torch
from transformers.utils import FEATURE_EXTRACTOR_NAME


if is_speech_available() and is_torch_available():
 from transformers import SpeechTaFeatureExtractor, SpeechTaProcessor

 from .test_feature_extraction_speechta import floats_list


lowercase__   			=      get_tests_dir('fixtures/test_sentencepiece_bpe_char.model')




@require_torch
class   __snake_case			(	unittest.TestCase							):



      def     lowerCamelCase_  (		self)      ->     Dict:





        '''simple docstring'''





        a__:	Any     				=      tempfile.mkdtemp()

        a__:	Optional[Any]     				=      SpeechTaTokenizer(lowercase)
        tokenizer.save_pretrained(self.tmpdirname)

        a__:	Optional[Any]     				=      {
            'feature_size': 1,
            'padding_value': 0.0,
            'sampling_rate': 1_60_00,
            'do_normalize': False,
            'num_mel_bins': 80,
            'hop_length': 16,
            'win_length': 64,
            'win_function': 'hann_window',
            'fmin': 80,
            'fmax': 76_00,
            'mel_floor': 1e-10,
            'reduction_factor': 2,
            'return_attention_mask': True,
        }

        a__:	List[str]     				=      os.path.join(self.tmpdirname       ,     lowercase)
        with open(self.feature_extraction_file       ,     'w'       ,     encoding='utf-8') as fp:
          fp.write(json.dumps(lowercase) + '\n')



      def     lowerCamelCase_  (		self       ,     **lowercase)      ->     List[Any]:





        '''simple docstring'''





        return SpeechTaTokenizer.from_pretrained(self.tmpdirname       ,     **lowercase)



      def     lowerCamelCase_  (		self       ,     **lowercase)      ->     int:





        '''simple docstring'''





        return SpeechTaFeatureExtractor.from_pretrained(self.tmpdirname       ,     **lowercase)



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





        '''simple docstring'''





        shutil.rmtree(self.tmpdirname)



      def     lowerCamelCase_  (		self)      ->     Union[str, Any]:





        '''simple docstring'''





        a__:	Optional[Any]     				=      self.get_tokenizer()
        a__:	Dict     				=      self.get_feature_extractor()

        a__:	str     				=      SpeechTaProcessor(tokenizer=lowercase       ,     feature_extractor=lowercase)

        processor.save_pretrained(self.tmpdirname)
        a__:	Any     				=      SpeechTaProcessor.from_pretrained(self.tmpdirname)

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

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



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





        '''simple docstring'''





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

        a__:	Tuple     				=      self.get_tokenizer(bos_token='(BOS)'       ,     eos_token='(EOS)')
        a__:	List[Any]     				=      self.get_feature_extractor(do_normalize=lowercase       ,     padding_value=1.0)

        a__:	Optional[Any]     				=      SpeechTaProcessor.from_pretrained(
            self.tmpdirname       ,     bos_token='(BOS)'       ,     eos_token='(EOS)'       ,     do_normalize=lowercase       ,     padding_value=1.0)

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

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



      def     lowerCamelCase_  (		self)      ->     Any:





        '''simple docstring'''





        a__:	List[str]     				=      self.get_feature_extractor()
        a__:	Optional[int]     				=      self.get_tokenizer()

        a__:	Union[str, Any]     				=      SpeechTaProcessor(tokenizer=lowercase       ,     feature_extractor=lowercase)

        a__:	Dict     				=      floats_list((3, 10_00))

        a__:	Any     				=      feature_extractor(audio=lowercase       ,     return_tensors='np')
        a__:	Tuple     				=      processor(audio=lowercase       ,     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     lowerCamelCase_  (		self)      ->     Dict:





        '''simple docstring'''





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

        a__:	List[str]     				=      SpeechTaProcessor(tokenizer=lowercase       ,     feature_extractor=lowercase)

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

        a__:	Optional[int]     				=      feature_extractor(audio_target=lowercase       ,     return_tensors='np')
        a__:	str     				=      processor(audio_target=lowercase       ,     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     lowerCamelCase_  (		self)      ->     List[Any]:





        '''simple docstring'''





        a__:	int     				=      self.get_feature_extractor()
        a__:	str     				=      self.get_tokenizer()

        a__:	Union[str, Any]     				=      SpeechTaProcessor(tokenizer=lowercase       ,     feature_extractor=lowercase)

        a__:	List[str]     				=      'This is a test string'

        a__:	Union[str, Any]     				=      processor(text=lowercase)
        a__:	int     				=      tokenizer(lowercase)

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



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





        '''simple docstring'''





        a__:	Any     				=      self.get_feature_extractor()
        a__:	Dict     				=      self.get_tokenizer()

        a__:	Dict     				=      SpeechTaProcessor(tokenizer=lowercase       ,     feature_extractor=lowercase)

        a__:	str     				=      'This is a test string'

        a__:	Any     				=      processor(text_target=lowercase)
        a__:	Optional[Any]     				=      tokenizer(lowercase)

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



      def     lowerCamelCase_  (		self)      ->     Union[str, Any]:





        '''simple docstring'''





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

        a__:	Optional[Any]     				=      SpeechTaProcessor(tokenizer=lowercase       ,     feature_extractor=lowercase)

        a__:	Optional[int]     				=      [[1, 4, 5, 8, 1, 0, 8], [3, 4, 3, 1, 1, 8, 9]]

        a__:	Any     				=      processor.batch_decode(lowercase)
        a__:	Optional[Any]     				=      tokenizer.batch_decode(lowercase)

        self.assertListEqual(lowercase       ,     lowercase)



      def     lowerCamelCase_  (		self)      ->     Union[str, Any]:





        '''simple docstring'''





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

        a__:	List[Any]     				=      SpeechTaProcessor(tokenizer=lowercase       ,     feature_extractor=lowercase)

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



"""simple docstring"""
from __future__ import annotations

import sys







def 		__a  (      _SCREAMING_SNAKE_CASE  )      ->int:
  if n < 0:
    raise ValueError('Negative arguments are not supported'  )
  return _fib(_SCREAMING_SNAKE_CASE  )[0]







def 		__a  (      _SCREAMING_SNAKE_CASE  )      ->tuple[int, int]:
  if n == 0:  # (F(0), F(1))
    return (0, 1)

  # F(2n) = F(n)[2F(n+1) − F(n)]
  # F(2n+1) = F(n+1)^2+F(n)^2
  a__				,       a__:	Optional[int]     				=      _fib(n // 2  )
  a__:	List[str]     				=      a * (b * 2 - a)
  a__:	Dict     				=      a * a + b * b
  return (d, c + d) if n % 2 else (c, d)


if __name__ == "__main__":
 lowercase__   			=      int(sys.argv[1])
 print(f"fibonacci({n}) is {fibonacci(n)}")


