






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


_UpperCamelCase		:  Any						=		5_0_3_5_8
_UpperCamelCase		:  Any						=		5_0_3_6_2

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







    def       UpperCamelCase_				(      self	):
      lowercase							   =	'openai/whisper-small.en'
      lowercase							   =	tempfile.mkdtemp()







    def       UpperCamelCase_				(      self							,		**_lowerCamelCase	):
      return WhisperTokenizer.from_pretrained(self.checkpoint							,		**_lowerCamelCase	)







    def       UpperCamelCase_				(      self							,		**_lowerCamelCase	):
      return WhisperFeatureExtractor.from_pretrained(self.checkpoint							,		**_lowerCamelCase	)







    def       UpperCamelCase_				(      self	):
      shutil.rmtree(self.tmpdirname	)







    def       UpperCamelCase_				(      self	):
      lowercase							   =	self.get_tokenizer()
      lowercase							   =	self.get_feature_extractor()

      lowercase							   =	WhisperProcessor(tokenizer=_lowerCamelCase							,		feature_extractor=_lowerCamelCase	)

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

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

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







    def       UpperCamelCase_				(      self	):
      lowercase							   =	WhisperProcessor(tokenizer=self.get_tokenizer()							,		feature_extractor=self.get_feature_extractor()	)
      processor.save_pretrained(self.tmpdirname	)

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

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

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

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







    def       UpperCamelCase_				(      self	):
      lowercase							   =	self.get_feature_extractor()
      lowercase							   =	self.get_tokenizer()

      lowercase							   =	WhisperProcessor(tokenizer=_lowerCamelCase							,		feature_extractor=_lowerCamelCase	)

      lowercase							   =	floats_list((3, 1_0_0_0)	)

      lowercase							   =	feature_extractor(_lowerCamelCase							,		return_tensors='np'	)
      lowercase							   =	processor(_lowerCamelCase							,		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	):
      lowercase							   =	self.get_feature_extractor()
      lowercase							   =	self.get_tokenizer()

      lowercase							   =	WhisperProcessor(tokenizer=_lowerCamelCase							,		feature_extractor=_lowerCamelCase	)

      lowercase							   =	'This is a test string'

      lowercase							   =	processor(text=_lowerCamelCase	)

      lowercase							   =	tokenizer(_lowerCamelCase	)

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







    def       UpperCamelCase_				(      self	):
      lowercase							   =	self.get_feature_extractor()
      lowercase							   =	self.get_tokenizer()

      lowercase							   =	WhisperProcessor(tokenizer=_lowerCamelCase							,		feature_extractor=_lowerCamelCase	)

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

      lowercase							   =	processor.batch_decode(_lowerCamelCase	)
      lowercase							   =	tokenizer.batch_decode(_lowerCamelCase	)

      self.assertListEqual(_lowerCamelCase							,		_lowerCamelCase	)







    def       UpperCamelCase_				(      self	):
      lowercase							   =	self.get_feature_extractor()
      lowercase							   =	self.get_tokenizer()

      lowercase							   =	WhisperProcessor(tokenizer=_lowerCamelCase							,		feature_extractor=_lowerCamelCase	)

      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	):
      lowercase							   =	self.get_feature_extractor()
      lowercase							   =	self.get_tokenizer()

      lowercase							   =	WhisperProcessor(tokenizer=_lowerCamelCase							,		feature_extractor=_lowerCamelCase	)
      lowercase							   =	processor.get_decoder_prompt_ids(task='transcribe'							,		no_timestamps=_lowerCamelCase	)

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

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







    def       UpperCamelCase_				(      self	):
      lowercase							   =	WhisperProcessor(tokenizer=self.get_tokenizer()							,		feature_extractor=self.get_feature_extractor()	)
      lowercase							   =	processor.get_prompt_ids('Mr. Quilter'	)
      lowercase							   =	processor.tokenizer.decode(_lowerCamelCase	)

      self.assertListEqual(prompt_ids.tolist()							,		[5_0_3_6_0, 1_7_7_0, 1_3, 2_2_6_4, 3_4_6, 3_5_3]	)
      self.assertEqual(_lowerCamelCase							,		'<|startofprev|> Mr. Quilter'	)







    def       UpperCamelCase_				(      self	):
      lowercase							   =	WhisperProcessor(tokenizer=self.get_tokenizer()							,		feature_extractor=self.get_feature_extractor()	)
      lowercase							   =	processor.get_prompt_ids(''	)
      lowercase							   =	processor.tokenizer.decode(_lowerCamelCase	)

      self.assertListEqual(prompt_ids.tolist()							,		[5_0_3_6_0, 2_2_0]	)
      self.assertEqual(_lowerCamelCase							,		'<|startofprev|> '	)







    def       UpperCamelCase_				(      self	):
      lowercase							   =	WhisperProcessor(tokenizer=self.get_tokenizer()							,		feature_extractor=self.get_feature_extractor()	)

      def _test_prompt_error_raised_helper(_lowerCamelCase							,		_lowerCamelCase	):
        with pytest.raises(_lowerCamelCase	) as excinfo:
          processor.get_prompt_ids(_lowerCamelCase	)
        lowercase							   =	F'Encountered text in the prompt corresponding to disallowed special token: {special_token}.'
        self.assertEqual(_lowerCamelCase							,		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"""



_UpperCamelCase		:  str						=		1_0**8
def 						_SCREAMING_SNAKE_CASE			(   __snake_case      :  int   ):





  '''simple docstring'''





  if n % 10 == 0:
    return False
  lowercase							   =	str(__snake_case   )
  return s == s[::-1]
def 						_SCREAMING_SNAKE_CASE			(   ):





  '''simple docstring'''





  lowercase							   =	set()
  lowercase							   =	1
  lowercase							   =	5
  while sum_squares < LIMIT:
    lowercase							   =	first_square + 1
    while sum_squares < LIMIT:
      if is_palindrome(__snake_case   ):
        answer.add(__snake_case   )
      last_square += 1
      sum_squares += last_square**2
    first_square += 1
    lowercase							   =	first_square**2 + (first_square + 1) ** 2

  return sum(__snake_case   )


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


