
import json
import os
import unittest

from transformers import HerbertTokenizer, HerbertTokenizerFast
from transformers.models.herbert.tokenization_herbert import VOCAB_FILES_NAMES
from transformers.testing_utils import get_tests_dir, require_tokenizers, slow

from ...test_tokenization_common import TokenizerTesterMixin


@require_tokenizers
class 	UpperCamelCase__       (  UpperCAmelCase__						,			unittest.TestCase):

						'''simple docstring'''



						__a     :    Tuple												=			HerbertTokenizer
						__a     :    Tuple												=			HerbertTokenizerFast
						__a     :    Tuple												=			True


						def    A__       (  self	)  ->Optional[Any]:
									super().setUp()

									# Use a simpler test file without japanese/chinese characters
									with open(F"""{get_tests_dir()}/fixtures/sample_text_no_unicode.txt"""  , encoding='utf-8'	) as f_data:
												UpperCAmelCase__		:Optional[int] 		=    f_data.read().replace('\n\n'  , '\n'	).strip()

									UpperCAmelCase__		:List[str] 		=    [
									    '''<s>''',
									    '''</s>''',
									    '''l''',
									    '''o''',
									    '''w''',
									    '''e''',
									    '''r''',
									    '''s''',
									    '''t''',
									    '''i''',
									    '''d''',
									    '''n''',
									    '''w</w>''',
									    '''r</w>''',
									    '''t</w>''',
									    '''lo''',
									    '''low''',
									    '''er</w>''',
									    '''low</w>''',
									    '''lowest</w>''',
									    '''newer</w>''',
									    '''wider</w>''',
									    ''',</w>''',
									    '''<unk>''',
									]
									UpperCAmelCase__		:Any 		=    dict(zip(SCREAMING_SNAKE_CASE_  , range(len(SCREAMING_SNAKE_CASE_	)	)	)	)
									UpperCAmelCase__		:Any 		=    ['''l o 123''', '''lo w 1456''', '''e r</w> 1789''', '''''']

									UpperCAmelCase__		:int 		=    os.path.join(self.tmpdirname  , VOCAB_FILES_NAMES['vocab_file']	)
									UpperCAmelCase__		:Optional[Any] 		=    os.path.join(self.tmpdirname  , VOCAB_FILES_NAMES['merges_file']	)
									with open(self.vocab_file  , 'w'	) as fp:
												fp.write(json.dumps(SCREAMING_SNAKE_CASE_	)	)
									with open(self.merges_file  , 'w'	) as fp:
												fp.write('\n'.join(SCREAMING_SNAKE_CASE_	)	)


						def    A__       (  self  , A	)  ->Any:
									UpperCAmelCase__		:List[Any] 		=    '''lower newer'''
									UpperCAmelCase__		:Dict 		=    '''lower newer'''
									return input_text, output_text


						def    A__       (  self	)  ->int:
									UpperCAmelCase__		:str 		=    self.tokenizer_class(vocab_file=self.vocab_file  , merges_file=self.merges_file	)

									UpperCAmelCase__		:List[str] 		=    '''lower'''
									UpperCAmelCase__		:List[Any] 		=    ['''low''', '''er</w>''']
									UpperCAmelCase__		:Dict 		=    tokenizer.tokenize(SCREAMING_SNAKE_CASE_	)
									self.assertListEqual(SCREAMING_SNAKE_CASE_  , SCREAMING_SNAKE_CASE_	)

									UpperCAmelCase__		:List[str] 		=    tokens + ['''<unk>''']
									UpperCAmelCase__		:Optional[int] 		=    [16, 17, 23]
									self.assertListEqual(tokenizer.convert_tokens_to_ids(SCREAMING_SNAKE_CASE_	)  , SCREAMING_SNAKE_CASE_	)


						def    A__       (  self	)  ->Dict:
									if not self.test_rust_tokenizer:
												return

									UpperCAmelCase__		:Union[str, Any] 		=    self.get_tokenizer()
									UpperCAmelCase__		:int 		=    self.get_rust_tokenizer()

									UpperCAmelCase__		:Optional[int] 		=    '''lower,newer'''

									UpperCAmelCase__		:List[Any] 		=    tokenizer.tokenize(SCREAMING_SNAKE_CASE_	)
									UpperCAmelCase__		:List[Any] 		=    rust_tokenizer.tokenize(SCREAMING_SNAKE_CASE_	)
									self.assertListEqual(SCREAMING_SNAKE_CASE_  , SCREAMING_SNAKE_CASE_	)

									UpperCAmelCase__		:Dict 		=    tokenizer.encode(SCREAMING_SNAKE_CASE_  , add_special_tokens=SCREAMING_SNAKE_CASE_	)
									UpperCAmelCase__		:List[Any] 		=    rust_tokenizer.encode(SCREAMING_SNAKE_CASE_  , add_special_tokens=SCREAMING_SNAKE_CASE_	)
									self.assertListEqual(SCREAMING_SNAKE_CASE_  , SCREAMING_SNAKE_CASE_	)

									UpperCAmelCase__		:List[Any] 		=    self.get_rust_tokenizer()
									UpperCAmelCase__		:Union[str, Any] 		=    tokenizer.encode(SCREAMING_SNAKE_CASE_	)
									UpperCAmelCase__		:Dict 		=    rust_tokenizer.encode(SCREAMING_SNAKE_CASE_	)
									self.assertListEqual(SCREAMING_SNAKE_CASE_  , SCREAMING_SNAKE_CASE_	)


						@slow
						def    A__       (  self	)  ->int:
									UpperCAmelCase__		:Optional[Any] 		=    self.tokenizer_class.from_pretrained('allegro/herbert-base-cased'	)

									UpperCAmelCase__		:List[str] 		=    tokenizer.encode('konstruowanie sekwencji'  , add_special_tokens=SCREAMING_SNAKE_CASE_	)
									UpperCAmelCase__		:List[str] 		=    tokenizer.encode('konstruowanie wielu sekwencji'  , add_special_tokens=SCREAMING_SNAKE_CASE_	)

									UpperCAmelCase__		:List[str] 		=    tokenizer.build_inputs_with_special_tokens(SCREAMING_SNAKE_CASE_	)
									UpperCAmelCase__		:Optional[int] 		=    tokenizer.build_inputs_with_special_tokens(SCREAMING_SNAKE_CASE_  , SCREAMING_SNAKE_CASE_	)

									assert encoded_sentence == [0] + text + [2]
									assert encoded_pair == [0] + text + [2] + text_a + [2]







'''simple docstring'''





def   A			(							A_				:       int							):
						return n * (2 * n - 1)

def   A			(							A_				:       int							):
						snake_case							:  Optional[Any]			=     (1 + 24 * n) ** 0.5
						return ((1 + root) / 6) % 1 == 0

def   A			(							A_				:       int = 144							):
						snake_case							:  Any			=     start
						snake_case							:  Any			=     hexagonal_num(A_							)
						while not is_pentagonal(A_							):
												n += 1
												snake_case							:  Optional[Any]			=     hexagonal_num(A_							)
						return num


if __name__ == "__main__":
						print(f'''{solution()} = ''')

