



import json
import os
import shutil
import tempfile
import unittest

from transformers.models.wavaveca import WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor
from transformers.models.wavaveca.tokenization_wavaveca import VOCAB_FILES_NAMES
from transformers.utils import FEATURE_EXTRACTOR_NAME

from .test_feature_extraction_wavaveca import floats_list


class 	snake_case_			(unittest.TestCase	):




       """simple docstring"""






       def 			A_ (  self):

             """simple docstring"""





             UpperCAmelCase_	:						List[str]					   =		"<pad> <s> </s> <unk> | E T A O N I H S R D L U M W C F G Y P B V K \' X J Q Z".split(" ")
             UpperCAmelCase_	:						Union[str, Any]					   =		dict(zip(__UpperCAmelCase  ,range(len(__UpperCAmelCase))))

             UpperCAmelCase_	:						List[str]					   =		{
                 "pad_token": "<pad>",
                 "unk_token": "<unk>",
                 "bos_token": "<s>",
                 "eos_token": "</s>",
             }
             UpperCAmelCase_	:						Union[str, Any]					   =		{
                 "feature_size": 1,
                 "padding_value": 0.0,
                 "sampling_rate": 16000,
                 "return_attention_mask": False,
                 "do_normalize": True,
             }

             UpperCAmelCase_	:						List[str]					   =		tempfile.mkdtemp()
             UpperCAmelCase_	:						str					   =		os.path.join(self.tmpdirname  ,VOCAB_FILES_NAMES["vocab_file"])
             UpperCAmelCase_	:						Dict					   =		os.path.join(self.tmpdirname  ,__UpperCAmelCase)
             with open(self.vocab_file  ,"w"  ,encoding="utf-8") as fp:
                   fp.write(json.dumps(__UpperCAmelCase) + "\n")

             with open(self.feature_extraction_file  ,"w"  ,encoding="utf-8") as fp:
                   fp.write(json.dumps(__UpperCAmelCase) + "\n")



       def 			A_ (  self  ,**lowercase):

             """simple docstring"""





             UpperCAmelCase_	:						str					   =		self.add_kwargs_tokens_map.copy()
             kwargs.update(__UpperCAmelCase)
             return WavaVecaCTCTokenizer.from_pretrained(self.tmpdirname  ,**__UpperCAmelCase)



       def 			A_ (  self  ,**lowercase):

             """simple docstring"""





             return WavaVecaFeatureExtractor.from_pretrained(self.tmpdirname  ,**__UpperCAmelCase)



       def 			A_ (  self):

             """simple docstring"""





             shutil.rmtree(self.tmpdirname)



       def 			A_ (  self):

             """simple docstring"""





             UpperCAmelCase_	:						int					   =		self.get_tokenizer()
             UpperCAmelCase_	:						Dict					   =		self.get_feature_extractor()

             UpperCAmelCase_	:						Optional[int]					   =		WavaVecaProcessor(tokenizer=__UpperCAmelCase  ,feature_extractor=__UpperCAmelCase)

             processor.save_pretrained(self.tmpdirname)
             UpperCAmelCase_	:						Optional[Any]					   =		WavaVecaProcessor.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 			A_ (  self):

             """simple docstring"""





             UpperCAmelCase_	:						Any					   =		WavaVecaProcessor(tokenizer=self.get_tokenizer()  ,feature_extractor=self.get_feature_extractor())
             processor.save_pretrained(self.tmpdirname)

             UpperCAmelCase_	:						Dict					   =		self.get_tokenizer(bos_token="(BOS)"  ,eos_token="(EOS)")
             UpperCAmelCase_	:						Dict					   =		self.get_feature_extractor(do_normalize=__UpperCAmelCase  ,padding_value=1.0)

             UpperCAmelCase_	:						Tuple					   =		WavaVecaProcessor.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 			A_ (  self):

             """simple docstring"""





             UpperCAmelCase_	:						int					   =		self.get_feature_extractor()
             UpperCAmelCase_	:						Optional[Any]					   =		self.get_tokenizer()

             UpperCAmelCase_	:						Dict					   =		WavaVecaProcessor(tokenizer=__UpperCAmelCase  ,feature_extractor=__UpperCAmelCase)

             UpperCAmelCase_	:						List[Any]					   =		floats_list((3, 1000))

             UpperCAmelCase_	:						List[Any]					   =		feature_extractor(__UpperCAmelCase  ,return_tensors="np")
             UpperCAmelCase_	:						Tuple					   =		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 			A_ (  self):

             """simple docstring"""





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

             UpperCAmelCase_	:						List[str]					   =		WavaVecaProcessor(tokenizer=__UpperCAmelCase  ,feature_extractor=__UpperCAmelCase)

             UpperCAmelCase_	:						int					   =		"This is a test string"

             UpperCAmelCase_	:						Union[str, Any]					   =		processor(text=__UpperCAmelCase)

             UpperCAmelCase_	:						int					   =		tokenizer(__UpperCAmelCase)

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



       def 			A_ (  self):

             """simple docstring"""





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

             UpperCAmelCase_	:						str					   =		WavaVecaProcessor(tokenizer=__UpperCAmelCase  ,feature_extractor=__UpperCAmelCase)

             UpperCAmelCase_	:						Optional[Any]					   =		[[1, 4, 5, 8, 1, 0, 8], [3, 4, 3, 1, 1, 8, 9]]

             UpperCAmelCase_	:						Optional[Any]					   =		processor.batch_decode(__UpperCAmelCase)
             UpperCAmelCase_	:						Optional[int]					   =		tokenizer.batch_decode(__UpperCAmelCase)

             self.assertListEqual(__UpperCAmelCase  ,__UpperCAmelCase)



       def 			A_ (  self):

             """simple docstring"""





             UpperCAmelCase_	:						Tuple					   =		self.get_feature_extractor()
             UpperCAmelCase_	:						str					   =		self.get_tokenizer()

             UpperCAmelCase_	:						Dict					   =		WavaVecaProcessor(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"  ,)


"""simple docstring"""

import math
from itertools import permutations






def 				A		(							snake_case :int						) ->      bool:

 if 1 < number < 4:
  # 2 and 3 are primes
  return True
 elif number < 2 or number % 2 == 0 or number % 3 == 0:
  # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
  return False

 # All primes number are in format of 6k +/- 1
 for i in range(5							,   int(math.sqrt(snake_case						) + 1						)							,   6						):
  if number % i == 0 or number % (i + 2) == 0:
   return False
 return True






def 				A		(							snake_case :int							,   snake_case :list						) ->      bool:
 __UpperCamelCase    ,      __UpperCamelCase							    =			0, len(snake_case						) - 1
 while left <= right:
  __UpperCamelCase							    =			(left + right) // 2
  if prime_list[middle] == target:
   return True
  elif prime_list[middle] < target:
   __UpperCamelCase							    =			middle + 1
  else:
   __UpperCamelCase							    =			middle - 1

 return False






def 				A		(							) ->      int:
 __UpperCamelCase							    =			[n for n in range(1_0_0_1							,   1_0_0_0_0							,   2						) if is_prime(snake_case						)]
 __UpperCamelCase							    =			[]

 for number in prime_list:
  __UpperCamelCase							    =			[]

  for prime_member in permutations(list(str(snake_case						)						)						):
   __UpperCamelCase							    =			int(''.join(snake_case						)						)

   if prime % 2 == 0:
    continue

   if search(snake_case							,   snake_case						):
    tmp_numbers.append(snake_case						)

  tmp_numbers.sort()
  if len(snake_case						) >= 3:
   candidates.append(snake_case						)

 __UpperCamelCase							    =			[]
 for candidate in candidates:
  __UpperCamelCase							    =			len(snake_case						)
  __UpperCamelCase							    =			False

  for i in range(snake_case						):
   for j in range(i + 1							,   snake_case						):
    for k in range(j + 1							,   snake_case						):
     if (
         abs(candidate[i] - candidate[j]						)
         == abs(candidate[j] - candidate[k]						)
         and len({candidate[i], candidate[j], candidate[k]}						) == 3
     ):
      passed.append(
          sorted([candidate[i], candidate[j], candidate[k]]						)						)
      __UpperCamelCase							    =			True

     if found:
      break
    if found:
     break
   if found:
    break

 __UpperCamelCase							    =			set()
 for seq in passed:
  answer.add(''.join([str(snake_case						) for i in seq]						)						)

 return max(int(snake_case						) for x in answer						)


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



