"""simple docstring"""




import json
import os
import unittest
from typing import Tuple

from transformers import WavaVecaPhonemeCTCTokenizer
from transformers.models.wavaveca.tokenization_wavaveca import VOCAB_FILES_NAMES
from transformers.models.wavaveca_phoneme.tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizerOutput
from transformers.testing_utils import require_phonemizer

from ...test_tokenization_common import TokenizerTesterMixin

@require_phonemizer
class       a_      (     snake_case__ ,		unittest.TestCase			):
					UpperCamelCase_ :	Any			=    WavaVecaPhonemeCTCTokenizer
					UpperCamelCase_ :	Union[str, Any]			=    False




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Tuple     ):
							super().setUp()

							lowerCAmelCase__        =   (
							    '<s> <pad> </s> <unk> n s t ə l a i k d m ɛ ɾ e ɪ p o ɐ z ð f j v b ɹ ʁ ʊ iː r w ʌ u ɡ æ aɪ ʃ h ɔ ɑː '
							    'ŋ ɚ eɪ β uː y ɑ̃ oʊ ᵻ eː θ aʊ ts oː ɔ̃ ɣ ɜ ɑ dʒ əl x ɜː ç ʒ tʃ ɔː ɑːɹ ɛ̃ ʎ ɔːɹ ʋ aː ɕ œ ø oːɹ ɲ yː '
							    'ʔ iə i5 s. tɕ ?? nʲ ɛː œ̃ ɭ ɔø ʑ tʲ ɨ ɛɹ ts. rʲ ɪɹ ɭʲ i.5 ɔɪ q sʲ u5 ʊɹ iɜ a5 iɛ5 øː ʕ ja əɜ th ɑ5 '
							    'oɪ dʲ ə5 tɕh ts.h mʲ ɯ dʑ vʲ e̞ tʃʲ ei5 o5 onɡ5 ɑu5 iɑ5 ai5 aɪɚ kh ə1 ʐ i2 ʉ ħ t[ aɪə ʲ ju ə2 u2 oɜ '
							    'pː iɛɜ ou5 y5 uɜ tː uo5 d[ uoɜ tsh ɑɜ ɵ i̪5 uei5 ɟ aɜ ɑɨ i.ɜ eʊ o2 ɐ̃ ä pʲ kʲ n̩ ɒ ph ɑu2 uɨ əɪ ɫ ɬ '
							    'yɜ bʲ ɑ2 s̪ aiɜ χ ɐ̃ʊ̃ 1 ə4 yæɜ a2 ɨː t̪ iouɜ ũ onɡɜ aɨ iɛ2 ɔɨ ɑuɜ o̞ ei2 iou2 c kː y2 ɖ oe dˤ yɛɜ '
							    'əʊ S ɡʲ onɡ2 u" eiɜ ʈ ɯᵝ iou5 dZ r̝̊ i.2 tS s^ ʝ yə5 iɑɜ uə5 pf ɨu iɑ2 ou2 ər2 fʲ ai2 r̝ uəɜ ɳ əɨ '
							    'ua5 uɪ ɽ bː yu5 uo2 yɛ5 l̩ ɻ ərɜ ʂ i̪2 ouɜ uaɜ a. a.ː yæ5 dː r̩ ee ɪu ər5 i̪ ɜ æi u: i.ː t^ o1 ɪ^ '
							    'ai ueiɜ æː ɛɪ eə i. ɴ ie ua2 ɑ1 o4 tʃː o: ɑ: u1 N i̪1 au yæ2 u. qː yəɜ y: kʰ tʃʰ iʊ sx õ uo tʰ '
							    'uai5 bʰ u.ː uə2 ʊə d^ s̪ː yiɜ dʰ r. oe: i1 ɟː yu2 nʲʲ i̪4 uei2 tsʲ ɸ ĩ ɑ4 t̪ː eɑ u4 e: tsː ʈʰ ɡʰ '
							    'ɯɯ dʒʲ ʂʲ X ɵː uaiɜ tɕʲ ã t^ː ẽː yɛ2 cː i.1 ɛʊ dˤdˤ dʒː i4 ɡː yi ɕʲ ɟʰ pʰ dʑʲ yuɜ ua1 ua4 æiː ɐɐ '
							    'ui iou1 ʊː a1 iou4 cʰ iɛ1 yə2 ɖʰ ẽ ʒʲ ää ər4 iːː ɪː iɑ1 ər1 œː øi ɪuː cʰcʰ əː1 iː1 ũ kʰː o̞o̞ xʲ '
							    'ou1 iɛ4 e̞e̞ y1 dzː dʲʲ dʰː ɯᵝɯᵝ lː uo1 i.4 i: yɛ5ʲ a4'
							).split(""" """     )
							lowerCAmelCase__        =   dict(zip(_A  ,						range(len(_A     )     )     )     )

							lowerCAmelCase__        =   {'pad_token': '<pad>', 'unk_token': '<unk>', 'bos_token': '<s>', 'eos_token': '</s>'}

							lowerCAmelCase__        =   os.path.join(self.tmpdirname  ,						VOCAB_FILES_NAMES["""vocab_file"""]     )
							with open(self.vocab_file  ,						"""w"""  ,						encoding="""utf-8"""     ) as fp:
									fp.write(json.dumps(_A     ) + """\n"""     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Dict  ,						snake_case__						:     Any  ,						snake_case__						:     List[Any]=False  ,						snake_case__						:     str=20  ,						snake_case__						:     Tuple=5     ):
							lowerCAmelCase__        =   [(i, tokenizer.decode([i]  ,						clean_up_tokenization_spaces=_A     )) for i in range(len(_A     )     )]
							lowerCAmelCase__        =   list(filter(lambda snake_case__     : [t[0]] == tokenizer.encode(t[1]  ,						do_phonemize=_A     )  ,						_A     )     )
							if max_length is not None and len(_A     ) > max_length:
									lowerCAmelCase__        =   toks[:max_length]
							if min_length is not None and len(_A     ) < min_length and len(_A     ) > 0:
									while len(_A     ) < min_length:
											lowerCAmelCase__        =   toks + toks
        # toks_str = [t[1] for t in toks]
							lowerCAmelCase__        =   [t[0] for t in toks]

							# Ensure consistency
							lowerCAmelCase__        =   tokenizer.decode(_A  ,						clean_up_tokenization_spaces=_A     )
							if " " not in output_txt and len(_A     ) > 1:
									lowerCAmelCase__        =   (
									    tokenizer.decode([toks_ids[0]]  ,						clean_up_tokenization_spaces=_A     )
									    + ' '
									    + tokenizer.decode(toks_ids[1:]  ,						clean_up_tokenization_spaces=_A     )
									)
							if with_prefix_space:
									lowerCAmelCase__        =   ' ' + output_txt
							lowerCAmelCase__        =   tokenizer.encode(_A  ,						add_special_tokens=_A     )
							return output_txt, output_ids




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Any  ,						**snake_case__						:     str     ):
							kwargs.update(self.special_tokens_map     )
							return WavaVecaPhonemeCTCTokenizer.from_pretrained(self.tmpdirname  ,						**_A     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Optional[Any]     ):
							lowerCAmelCase__        =   self.tokenizer_class.from_pretrained("""facebook/wav2vec2-lv-60-espeak-cv-ft"""     )

							# check adding a single token
							tokenizer.add_tokens("""xxx"""     )
							lowerCAmelCase__        =   tokenizer("""m xxx ɪ"""  ,						do_phonemize=_A     ).input_ids
							self.assertEqual(_A  ,						[13, 392, 17]     )  # xxx should be last token

							tokenizer.add_tokens(["""aaa""", """bbb""", """ccc"""]     )
							lowerCAmelCase__        =   tokenizer("""m aaa ɪ ccc"""  ,						do_phonemize=_A     ).input_ids
							self.assertEqual(_A  ,						[13, 393, 17, 395]     )  # aaa and ccc should be after xxx and 2 after aaa

							lowerCAmelCase__        =   tokenizer("""maɪ c"""  ,						do_phonemize=_A     ).input_ids
							self.assertEqual(_A  ,						[3, 200]     )  # mai should be <unk> (=3)




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Dict     ):
							lowerCAmelCase__        =   self.tokenizer_class.from_pretrained("""facebook/wav2vec2-lv-60-espeak-cv-ft"""     )

							lowerCAmelCase__        =   'Hello how are you'
							lowerCAmelCase__        =   tokenizer.phonemize(_A  ,						phonemizer_lang="""en-us"""     )
							self.assertEqual(_A  ,						"""h ə l oʊ h aʊ ɑːɹ j uː"""     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Optional[int]     ):
							lowerCAmelCase__        =   self.tokenizer_class.from_pretrained("""facebook/wav2vec2-lv-60-espeak-cv-ft"""     )

							lowerCAmelCase__        =   'Hello how are you'
							lowerCAmelCase__        =   tokenizer.phonemize(_A  ,						phonemizer_lang="""en-us"""     )
							self.assertEqual(tokenizer(_A     ).input_ids  ,						tokenizer(_A  ,						do_phonemize=_A     ).input_ids     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Union[str, Any]     ):
							lowerCAmelCase__        =   self.tokenizer_class.from_pretrained("""facebook/wav2vec2-lv-60-espeak-cv-ft"""     )
							lowerCAmelCase__        =   'Hello how are you'
							lowerCAmelCase__        =   tokenizer.phonemize(_A  ,						phonemizer_lang="""en-us"""     )

							lowerCAmelCase__        =   tokenizer.decode(tokenizer(_A     ).input_ids     )

							self.assertEqual(_A  ,						_A     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Dict     ):
							lowerCAmelCase__        =   self.tokenizer_class.from_pretrained("""facebook/wav2vec2-lv-60-espeak-cv-ft"""     )

							lowerCAmelCase__        =   [
							    [11, 5, 15, tokenizer.pad_token_id, 15, 8, 98],
							    [24, 22, 5, 24, 22, 5, 77],
							]
							lowerCAmelCase__        =   tokenizer.decode(sample_ids[0]     )
							lowerCAmelCase__        =   tokenizer.batch_decode(_A     )
							self.assertEqual(_A  ,						batch_tokens[0]     )
							self.assertEqual(_A  ,						["""k s ɾ ɾ l ɭʲ""", """j ð s j ð s oːɹ"""]     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     int     ):
							lowerCAmelCase__        =   self.tokenizer_class.from_pretrained(
							    """facebook/wav2vec2-lv-60-espeak-cv-ft"""  ,						word_delimiter_token="""|"""     )
							tokenizer.add_tokens("""|"""     )

							lowerCAmelCase__        =   'Hello how are you'
							lowerCAmelCase__        =   tokenizer.phonemize(_A  ,						phonemizer_lang="""en-us"""     )
							self.assertEqual(_A  ,						"""h ə l oʊ | h aʊ | ɑːɹ | j uː |"""     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Union[str, Any]     ):
							lowerCAmelCase__        =   self.tokenizer_class.from_pretrained(
							    """facebook/wav2vec2-lv-60-espeak-cv-ft"""  ,						word_delimiter_token="""|"""     )
							tokenizer.add_tokens("""|"""     )

							lowerCAmelCase__        =   'Hello how are you'
							lowerCAmelCase__        =   tokenizer.phonemize(_A  ,						phonemizer_lang="""en-us"""     )
							self.assertEqual(tokenizer(_A     ).input_ids  ,						tokenizer(_A  ,						do_phonemize=_A     ).input_ids     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     List[str]     ):
							lowerCAmelCase__        =   self.tokenizer_class.from_pretrained(
							    """facebook/wav2vec2-lv-60-espeak-cv-ft"""  ,						word_delimiter_token="""|"""     )
							tokenizer.add_tokens("""|"""     )

							# fmt: off
							lowerCAmelCase__        =   [
							    [11, 5, 15, tokenizer.pad_token_id, tokenizer.word_delimiter_token_id, 15, 8, tokenizer.word_delimiter_token_id, 98],
							    [tokenizer.word_delimiter_token_id, 24, 22, tokenizer.word_delimiter_token_id, 5, 24, 22, 5, 77],
							]
							# fmt: on

							# decode with word_del_token filter
							lowerCAmelCase__        =   tokenizer.decode(sample_ids[0]     )
							lowerCAmelCase__        =   tokenizer.batch_decode(_A     )
							self.assertEqual(_A  ,						batch_tokens[0]     )
							self.assertEqual(_A  ,						["""k s ɾ ɾ l ɭʲ""", """j ð s j ð s oːɹ"""]     )

							# decode with no word_del_token filter
							lowerCAmelCase__        =   tokenizer.decode(sample_ids[0]  ,						filter_word_delimiter_token=_A     )
							lowerCAmelCase__        =   tokenizer.batch_decode(_A  ,						filter_word_delimiter_token=_A     )
							self.assertEqual(_A  ,						batch_tokens[0]     )
							self.assertEqual(_A  ,						["""k s ɾ | ɾ l | ɭʲ""", """| j ð | s j ð s oːɹ"""]     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     List[str]     ):
							lowerCAmelCase__        =   self.tokenizer_class.from_pretrained(
							    """facebook/wav2vec2-lv-60-espeak-cv-ft"""  ,						word_delimiter_token="""|"""     )
							tokenizer.add_tokens("""|"""     )

							lowerCAmelCase__        =   'Hello how are you'
							lowerCAmelCase__        =   tokenizer.phonemize(_A  ,						phonemizer_lang="""en-us"""     )

							lowerCAmelCase__        =   tokenizer.decode(tokenizer(_A     ).input_ids  ,						filter_word_delimiter_token=_A     )

							self.assertEqual(_A  ,						_A     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     List[Any]     ):
							lowerCAmelCase__        =   self.tokenizer_class.from_pretrained(
							    """facebook/wav2vec2-lv-60-espeak-cv-ft"""  ,						word_delimiter_token="""|"""     )
							tokenizer.add_tokens("""|"""     )

							lowerCAmelCase__        =   'Hello how are you'
							lowerCAmelCase__        =   tokenizer.phonemize(_A  ,						phonemizer_lang="""en-us"""     )

							lowerCAmelCase__        =   tokenizer.decode(tokenizer(_A     ).input_ids  ,						filter_word_delimiter_token=_A     )

							self.assertEqual(""" """.join([p.strip() for p in phonemes.split(""" |"""     )]     ).strip()  ,						_A     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Optional[Any]     ):
							lowerCAmelCase__        =   self.tokenizer_class.from_pretrained(
							    """facebook/wav2vec2-lv-60-espeak-cv-ft"""  ,						word_delimiter_token=_A     )
							lowerCAmelCase__        =   'Hello how are you'

							lowerCAmelCase__        =   tokenizer(_A  ,						phonemizer_lang="""en-us"""     ).input_ids
							lowerCAmelCase__        =   tokenizer(_A  ,						phonemizer_lang="""fr-fr"""     ).input_ids

							self.assertNotEqual(_A  ,						_A     )

							lowerCAmelCase__        =   tokenizer.decode(_A     )
							lowerCAmelCase__        =   tokenizer.decode(_A     )

							self.assertEqual(_A  ,						"""h ə l oʊ h aʊ ɑːɹ j uː"""     )
							self.assertEqual(_A  ,						"""ɛ l o h aʊ a ʁ j u"""     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Dict     ):
							lowerCAmelCase__        =   self.tokenizer_class.from_pretrained("""facebook/wav2vec2-lv-60-espeak-cv-ft"""     )
							lowerCAmelCase__        =   'Hello how Are you'
							lowerCAmelCase__        =   'hello how are you'

							lowerCAmelCase__        =   tokenizer(_A     ).input_ids
							lowerCAmelCase__        =   tokenizer(_A     ).input_ids

							self.assertEqual(_A  ,						_A     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     str     ):
							lowerCAmelCase__        =   self.tokenizer_class.from_pretrained("""facebook/wav2vec2-lv-60-espeak-cv-ft"""     )
							tokenizer.add_tokens(["""!""", """?"""]     )
							tokenizer.add_special_tokens({"""cls_token""": """$$$"""}     )

							# fmt: off
							lowerCAmelCase__        =   [
							    [11, 5, 15, tokenizer.pad_token_id, 15, 8, 98, 392, 392, 393, 392, 392, 393, 394, 394],
							    [24, 22, 5, 24, 22, 5, 77, tokenizer.pad_token_id, 394, 394],
							]
							# fmt: on

							lowerCAmelCase__        =   tokenizer.batch_decode(_A     )
							self.assertEqual(_A  ,						["""k s ɾ ɾ l ɭʲ!?!? $$$""", """j ð s j ð s oːɹ $$$"""]     )




					@staticmethod
					def 						_SCREAMING_SNAKE_CASE						(	snake_case__						:     Optional[int]  ,						snake_case__						:     Any     ):
							lowerCAmelCase__        =   [d[key] for d in offsets]
							return retrieved_list




					def 						_SCREAMING_SNAKE_CASE						(	self						:     int     ):
							lowerCAmelCase__        =   self.get_tokenizer(word_delimiter_token="""|"""     )
							tokenizer.add_tokens("""|"""     )

							# fmt: off
							# ksssɾɾ|ɾɾ<pad>ɾɾ|<pad>ɾlll|ɭʲ -> k s ɾ ɾ | ɾ l | ɭʲ"
							lowerCAmelCase__        =   [11, 5, 5, 5, 15, 15, tokenizer.pad_token_id, 15, 15, tokenizer.word_delimiter_token_id, tokenizer.pad_token_id, 15, 8, 8, 8, tokenizer.word_delimiter_token_id, 98]
							# fmt: on

							lowerCAmelCase__        =   tokenizer.decode(_A  ,						output_char_offsets=_A  ,						filter_word_delimiter_token=_A     )
							# check Wav2Vec2CTCTokenizerOutput keys for char
							self.assertEqual(len(outputs.keys()     )  ,						2     )
							self.assertTrue("""text""" in outputs     )
							self.assertTrue("""char_offsets""" in outputs     )
							self.assertTrue(isinstance(_A  ,						_A     )     )

							# check that order of chars is correct and identical for both outputs
							self.assertEqual(""" """.join(self.get_from_offsets(outputs["""char_offsets"""]  ,						"""char"""     )     )  ,						outputs.text     )
							self.assertListEqual(
							    self.get_from_offsets(outputs["""char_offsets"""]  ,						"""char"""     )  ,						["""k""", """s""", """ɾ""", """ɾ""", """|""", """ɾ""", """l""", """|""", """ɭʲ"""]     )

							# check that offsets are actually correct for char
							# 0-1 is 11, 1-4 is 5, 4-6 is first 15, 6-7 is <pad> (thus not shown), 7-9 is second 15, 9-10 is word_delimiter_token,
							# 10-11 is <pad> (thus not shown), 11-12 is third 15, 12-15 is 8, 15-16 is word_delimiter_token, 16-17 is 98
							self.assertListEqual(
							    self.get_from_offsets(outputs["""char_offsets"""]  ,						"""start_offset"""     )  ,						[0, 1, 4, 7, 9, 11, 12, 15, 16]     )
							self.assertListEqual(
							    self.get_from_offsets(outputs["""char_offsets"""]  ,						"""end_offset"""     )  ,						[1, 4, 6, 9, 10, 12, 15, 16, 17]     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Optional[int]     ):
							lowerCAmelCase__        =   self.get_tokenizer(word_delimiter_token="""|"""     )

							def check_list_tuples_equal(snake_case__						:     List[Any]  ,						snake_case__						:     Union[str, Any]     ):
									self.assertTrue(isinstance(_A  ,						_A     )     )
									self.assertTrue(isinstance(outputs_list[0]  ,						_A     )     )

									# transform list to ModelOutput
									lowerCAmelCase__        =   WavaVecaPhonemeCTCTokenizerOutput(
									    {k: [d[k] for d in outputs_list] for k in outputs_list[0]}     )

									self.assertListEqual(outputs_batch["""text"""]  ,						outputs_batch_a["""text"""]     )

									def recursive_check(snake_case__						:     Optional[Any]  ,						snake_case__						:     Any     ):
											if isinstance(_A  ,						_A     ):
													[recursive_check(_A  ,						_A     ) for la, la in zip(_A  ,						_A     )]
											self.assertEqual(_A  ,						_A     )

									if "char_offsets" in outputs_batch:
											recursive_check(outputs_batch["""char_offsets"""]  ,						outputs_batch_a["""char_offsets"""]     )

        # fmt: off
							lowerCAmelCase__        =   [
							    [11, 5, 15, tokenizer.pad_token_id, 15, 4, 8, 98, 32, 32, 32, 32, 4, 33, tokenizer.word_delimiter_token_id, 32, 32, 33, 34, 34],
							    [24, 22, 5, tokenizer.word_delimiter_token_id, tokenizer.word_delimiter_token_id, 24, 22, 22, 22, 4, 5, 77, tokenizer.pad_token_id, 22, 22, 4, 34, 34, 34, 34],
							]
							# fmt: on

							# We assume that `decode` works as expected. All we will check now is
							# the output type is correct and the output is identical to `decode`

							# char
							lowerCAmelCase__        =   tokenizer.batch_decode(_A  ,						output_char_offsets=_A     )
							lowerCAmelCase__        =   [tokenizer.decode(_A  ,						output_char_offsets=_A     ) for ids in sample_ids]
							check_list_tuples_equal(_A  ,						_A     )




					@unittest.skip("""Wav2Vec2PhonemeTokenizer always lower cases letters to correctly map to phonemes"""     )
					def 						_SCREAMING_SNAKE_CASE						(	self						:     Dict     ):
							pass




					@unittest.skip("""Wav2Vec2PhonemeTokenizer always puts spaces between phonemes"""     )
					def 						_SCREAMING_SNAKE_CASE						(	self						:     int     ):
							pass




					@unittest.skip("""encodes to text to ids, but decodes ids to phonemes -> not possible to have internal consistency"""     )
					def 						_SCREAMING_SNAKE_CASE						(	self						:     Optional[int]     ):
							pass




					@unittest.skip("""Wav2Vec2PhonemeModel has no max model length => no testing"""     )
					def 						_SCREAMING_SNAKE_CASE						(	self						:     int     ):
							pass




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Dict     ):
							lowerCAmelCase__        =   self.get_tokenizers(do_lower_case=_A     )
							for tokenizer in tokenizers:
									with self.subTest(F"""{tokenizer.__class__.__name__}"""     ):
											lowerCAmelCase__        =   tokenizer.vocab_size
											lowerCAmelCase__        =   len(_A     )

											self.assertNotEqual(_A  ,						0     )

											# We usually have added tokens from the start in tests because our vocab fixtures are
											# smaller than the original vocabs - let's not assert this
											# self.assertEqual(vocab_size, all_size)

											lowerCAmelCase__        =   ['aaaaa bbbbbb', 'cccccccccdddddddd']
											lowerCAmelCase__        =   tokenizer.add_tokens(_A     )
											lowerCAmelCase__        =   tokenizer.vocab_size
											lowerCAmelCase__        =   len(_A     )

											self.assertNotEqual(_A  ,						0     )
											self.assertEqual(_A  ,						_A     )
											self.assertEqual(_A  ,						len(_A     )     )
											self.assertEqual(_A  ,						all_size + len(_A     )     )

											lowerCAmelCase__        =   tokenizer.encode("""aaaaa bbbbbb low cccccccccdddddddd l"""  ,						add_special_tokens=_A     )

											self.assertGreaterEqual(len(_A     )  ,						4     )
											self.assertGreater(tokens[0]  ,						tokenizer.vocab_size - 1     )
											self.assertGreater(tokens[-3]  ,						tokenizer.vocab_size - 1     )

											lowerCAmelCase__        =   {'eos_token': '>>>>|||<||<<|<<', 'pad_token': '<<<<<|||>|>>>>|>'}
											lowerCAmelCase__        =   tokenizer.add_special_tokens(_A     )
											lowerCAmelCase__        =   tokenizer.vocab_size
											lowerCAmelCase__        =   len(_A     )

											self.assertNotEqual(_A  ,						0     )
											self.assertEqual(_A  ,						_A     )
											self.assertEqual(_A  ,						len(_A     )     )
											self.assertEqual(_A  ,						all_size_a + len(_A     )     )

											lowerCAmelCase__        =   tokenizer.encode(
											    """>>>>|||<||<<|<< aaaaabbbbbb low cccccccccdddddddd <<<<<|||>|>>>>|> l"""  ,						add_special_tokens=_A     )

											self.assertGreaterEqual(len(_A     )  ,						6     )
											self.assertGreater(tokens[0]  ,						tokenizer.vocab_size - 1     )
											self.assertGreater(tokens[0]  ,						tokens[1]     )
											self.assertGreater(tokens[-3]  ,						tokenizer.vocab_size - 1     )
											self.assertGreater(tokens[-3]  ,						tokens[-4]     )
											self.assertEqual(tokens[0]  ,						tokenizer.eos_token_id     )
											self.assertEqual(tokens[-3]  ,						tokenizer.pad_token_id     )




					@unittest.skip("""The tokenizer shouldn\'t be used to encode input IDs (except for labels), only to decode."""     )
					def 						_SCREAMING_SNAKE_CASE						(	self						:     str     ):
							pass




					@unittest.skip("""The tokenizer shouldn\'t be used to encode input IDs (except for labels), only to decode."""     )
					def 						_SCREAMING_SNAKE_CASE						(	self						:     int     ):
							pass




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Tuple     ):
							# The default common tokenizer tests assumes that the output of `convert_tokens_to_string` is a string which
							# is not the case for Wav2Vec2PhonemeCTCTokenizer.
							lowerCAmelCase__        =   self.get_tokenizers(fast=_A  ,						do_lower_case=_A     )
							for tokenizer in tokenizers:
									with self.subTest(F"""{tokenizer.__class__.__name__}"""     ):
											lowerCAmelCase__        =   ['ð', 'ɪ', 's', 'ɪ', 'z', 'ɐ', 't', 'ɛ', 'k', 's', 't']
											lowerCAmelCase__        =   tokenizer.convert_tokens_to_string(_A     )

											self.assertIsInstance(output["""text"""]  ,						_A     )





"""simple docstring"""




from binascii import hexlify
from hashlib import shaaaa
from os import urandom

# RFC 3526 - More Modular Exponential (MODP) Diffie-Hellman groups for
# Internet Key Exchange (IKE) https://tools.ietf.org/html/rfc3526

__lowerCAmelCase    :							Any													=						{
    # 1536-bit
    5: {
        "prime": int(
            "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1"
            + "29024E088A67CC74020BBEA63B139B22514A08798E3404DD"
            + "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245"
            + "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED"
            + "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D"
            + "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F"
            + "83655D23DCA3AD961C62F356208552BB9ED529077096966D"
            + "670C354E4ABC9804F1746C08CA237327FFFFFFFFFFFFFFFF",
            base=16,
        ),
        "generator": 2,
    },
    # 2048-bit
    14: {
        "prime": int(
            "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1"
            + "29024E088A67CC74020BBEA63B139B22514A08798E3404DD"
            + "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245"
            + "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED"
            + "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D"
            + "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F"
            + "83655D23DCA3AD961C62F356208552BB9ED529077096966D"
            + "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B"
            + "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9"
            + "DE2BCBF6955817183995497CEA956AE515D2261898FA0510"
            + "15728E5A8AACAA68FFFFFFFFFFFFFFFF",
            base=16,
        ),
        "generator": 2,
    },
    # 3072-bit
    15: {
        "prime": int(
            "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1"
            + "29024E088A67CC74020BBEA63B139B22514A08798E3404DD"
            + "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245"
            + "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED"
            + "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D"
            + "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F"
            + "83655D23DCA3AD961C62F356208552BB9ED529077096966D"
            + "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B"
            + "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9"
            + "DE2BCBF6955817183995497CEA956AE515D2261898FA0510"
            + "15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64"
            + "ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7"
            + "ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B"
            + "F12FFA06D98A0864D87602733EC86A64521F2B18177B200C"
            + "BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31"
            + "43DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF",
            base=16,
        ),
        "generator": 2,
    },
    # 4096-bit
    16: {
        "prime": int(
            "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1"
            + "29024E088A67CC74020BBEA63B139B22514A08798E3404DD"
            + "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245"
            + "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED"
            + "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D"
            + "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F"
            + "83655D23DCA3AD961C62F356208552BB9ED529077096966D"
            + "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B"
            + "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9"
            + "DE2BCBF6955817183995497CEA956AE515D2261898FA0510"
            + "15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64"
            + "ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7"
            + "ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B"
            + "F12FFA06D98A0864D87602733EC86A64521F2B18177B200C"
            + "BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31"
            + "43DB5BFCE0FD108E4B82D120A92108011A723C12A787E6D7"
            + "88719A10BDBA5B2699C327186AF4E23C1A946834B6150BDA"
            + "2583E9CA2AD44CE8DBBBC2DB04DE8EF92E8EFC141FBECAA6"
            + "287C59474E6BC05D99B2964FA090C3A2233BA186515BE7ED"
            + "1F612970CEE2D7AFB81BDD762170481CD0069127D5B05AA9"
            + "93B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934063199"
            + "FFFFFFFFFFFFFFFF",
            base=16,
        ),
        "generator": 2,
    },
    # 6144-bit
    17: {
        "prime": int(
            "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E08"
            + "8A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B"
            + "302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9"
            + "A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE6"
            + "49286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8"
            + "FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D"
            + "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C"
            + "180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF695581718"
            + "3995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D"
            + "04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7D"
            + "B3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D226"
            + "1AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200C"
            + "BBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFC"
            + "E0FD108E4B82D120A92108011A723C12A787E6D788719A10BDBA5B26"
            + "99C327186AF4E23C1A946834B6150BDA2583E9CA2AD44CE8DBBBC2DB"
            + "04DE8EF92E8EFC141FBECAA6287C59474E6BC05D99B2964FA090C3A2"
            + "233BA186515BE7ED1F612970CEE2D7AFB81BDD762170481CD0069127"
            + "D5B05AA993B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934028492"
            + "36C3FAB4D27C7026C1D4DCB2602646DEC9751E763DBA37BDF8FF9406"
            + "AD9E530EE5DB382F413001AEB06A53ED9027D831179727B0865A8918"
            + "DA3EDBEBCF9B14ED44CE6CBACED4BB1BDB7F1447E6CC254B33205151"
            + "2BD7AF426FB8F401378CD2BF5983CA01C64B92ECF032EA15D1721D03"
            + "F482D7CE6E74FEF6D55E702F46980C82B5A84031900B1C9E59E7C97F"
            + "BEC7E8F323A97A7E36CC88BE0F1D45B7FF585AC54BD407B22B4154AA"
            + "CC8F6D7EBF48E1D814CC5ED20F8037E0A79715EEF29BE32806A1D58B"
            + "B7C5DA76F550AA3D8A1FBFF0EB19CCB1A313D55CDA56C9EC2EF29632"
            + "387FE8D76E3C0468043E8F663F4860EE12BF2D5B0B7474D6E694F91E"
            + "6DCC4024FFFFFFFFFFFFFFFF",
            base=16,
        ),
        "generator": 2,
    },
    # 8192-bit
    18: {
        "prime": int(
            "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1"
            + "29024E088A67CC74020BBEA63B139B22514A08798E3404DD"
            + "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245"
            + "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED"
            + "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D"
            + "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F"
            + "83655D23DCA3AD961C62F356208552BB9ED529077096966D"
            + "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B"
            + "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9"
            + "DE2BCBF6955817183995497CEA956AE515D2261898FA0510"
            + "15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64"
            + "ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7"
            + "ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B"
            + "F12FFA06D98A0864D87602733EC86A64521F2B18177B200C"
            + "BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31"
            + "43DB5BFCE0FD108E4B82D120A92108011A723C12A787E6D7"
            + "88719A10BDBA5B2699C327186AF4E23C1A946834B6150BDA"
            + "2583E9CA2AD44CE8DBBBC2DB04DE8EF92E8EFC141FBECAA6"
            + "287C59474E6BC05D99B2964FA090C3A2233BA186515BE7ED"
            + "1F612970CEE2D7AFB81BDD762170481CD0069127D5B05AA9"
            + "93B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934028492"
            + "36C3FAB4D27C7026C1D4DCB2602646DEC9751E763DBA37BD"
            + "F8FF9406AD9E530EE5DB382F413001AEB06A53ED9027D831"
            + "179727B0865A8918DA3EDBEBCF9B14ED44CE6CBACED4BB1B"
            + "DB7F1447E6CC254B332051512BD7AF426FB8F401378CD2BF"
            + "5983CA01C64B92ECF032EA15D1721D03F482D7CE6E74FEF6"
            + "D55E702F46980C82B5A84031900B1C9E59E7C97FBEC7E8F3"
            + "23A97A7E36CC88BE0F1D45B7FF585AC54BD407B22B4154AA"
            + "CC8F6D7EBF48E1D814CC5ED20F8037E0A79715EEF29BE328"
            + "06A1D58BB7C5DA76F550AA3D8A1FBFF0EB19CCB1A313D55C"
            + "DA56C9EC2EF29632387FE8D76E3C0468043E8F663F4860EE"
            + "12BF2D5B0B7474D6E694F91E6DBE115974A3926F12FEE5E4"
            + "38777CB6A932DF8CD8BEC4D073B931BA3BC832B68D9DD300"
            + "741FA7BF8AFC47ED2576F6936BA424663AAB639C5AE4F568"
            + "3423B4742BF1C978238F16CBE39D652DE3FDB8BEFC848AD9"
            + "22222E04A4037C0713EB57A81A23F0C73473FC646CEA306B"
            + "4BCBC8862F8385DDFA9D4B7FA2C087E879683303ED5BDD3A"
            + "062B3CF5B3A278A66D2A13F83F44F82DDF310EE074AB6A36"
            + "4597E899A0255DC164F31CC50846851DF9AB48195DED7EA1"
            + "B1D510BD7EE74D73FAF36BC31ECFA268359046F4EB879F92"
            + "4009438B481C6CD7889A002ED5EE382BC9190DA6FC026E47"
            + "9558E4475677E9AA9E3050E2765694DFC81F56E880B96E71"
            + "60C980DD98EDD3DFFFFFFFFFFFFFFFFF",
            base=16,
        ),
        "generator": 2,
    },
}

class       a_      :




					def __init__(	self						:     List[str]  ,						snake_case__						:     int = 14     ):
							if group not in primes:
									raise ValueError("""Unsupported Group"""     )
							lowerCAmelCase__        =   primes[group]["""prime"""]
							lowerCAmelCase__        =   primes[group]["""generator"""]

							lowerCAmelCase__        =   int(hexlify(urandom(32     )     )  ,						base=16     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Any     ):
							return hex(self.__private_key     )[2:]




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Union[str, Any]     ):
							lowerCAmelCase__        =   pow(self.generator  ,						self.__private_key  ,						self.prime     )
							return hex(snake_case__     )[2:]




					def 						_SCREAMING_SNAKE_CASE						(	self						:     List[str]  ,						snake_case__						:     int     ):
							# check if the other public key is valid based on NIST SP800-56
							return (
							    2 <= key <= self.prime - 2
							    and pow(snake_case__  ,						(self.prime - 1) // 2  ,						self.prime     ) == 1
							)




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Optional[Any]  ,						snake_case__						:     str     ):
							lowerCAmelCase__        =   int(snake_case__  ,						base=16     )
							if not self.is_valid_public_key(snake_case__     ):
									raise ValueError("""Invalid public key"""     )
							lowerCAmelCase__        =   pow(snake_case__  ,						self.__private_key  ,						self.prime     )
							return shaaaa(str(snake_case__     ).encode()     ).hexdigest()




					@staticmethod
					def 						_SCREAMING_SNAKE_CASE						(	snake_case__						:     int  ,						snake_case__						:     int     ):
							# check if the other public key is valid based on NIST SP800-56
							return (
							    2 <= remote_public_key_str <= prime - 2
							    and pow(snake_case__  ,						(prime - 1) // 2  ,						snake_case__     ) == 1
							)




					@staticmethod
					def 						_SCREAMING_SNAKE_CASE						(	snake_case__						:     str  ,						snake_case__						:     str  ,						snake_case__						:     int = 14     ):
							lowerCAmelCase__        =   int(snake_case__  ,						base=16     )
							lowerCAmelCase__        =   int(snake_case__  ,						base=16     )
							lowerCAmelCase__        =   primes[group]["""prime"""]
							if not DiffieHellman.is_valid_public_key_static(snake_case__  ,						snake_case__     ):
									raise ValueError("""Invalid public key"""     )
							lowerCAmelCase__        =   pow(snake_case__  ,						snake_case__  ,						snake_case__     )
							return shaaaa(str(snake_case__     ).encode()     ).hexdigest()


if __name__ == "__main__":
			import doctest

			doctest.testmod()




