




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_   ( A		,   unittest.TestCase							):




							'''simple docstring'''



							a__    	=  HerbertTokenizer
							a__    	=  HerbertTokenizerFast
							a__    	=  True





							def  _UpperCAmelCase  (       self							:						Optional[Any]      )      ->       str:
										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:
													SCREAMING_SNAKE_CASE     =       f_data.read().replace("""\n\n"""							,  """\n"""      ).strip()

										SCREAMING_SNAKE_CASE     =       [
										    """<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>""",
										]
										SCREAMING_SNAKE_CASE     =       dict(zip(a							,  range(len(a      )      )      )      )
										SCREAMING_SNAKE_CASE     =       ["""l o 123""", """lo w 1456""", """e r</w> 1789""", """"""]

										SCREAMING_SNAKE_CASE     =       os.path.join(self.tmpdirname							,  VOCAB_FILES_NAMES["""vocab_file"""]      )
										SCREAMING_SNAKE_CASE     =       os.path.join(self.tmpdirname							,  VOCAB_FILES_NAMES["""merges_file"""]      )
										with open(self.vocab_file							,  """w"""      ) as fp:
													fp.write(json.dumps(a      )      )
										with open(self.merges_file							,  """w"""      ) as fp:
													fp.write("""\n""".join(a      )      )





							def  _UpperCAmelCase  (       self							:						int							,  a							:						Union[str, Any]      )      ->       Dict:
										SCREAMING_SNAKE_CASE     =       """lower newer"""
										SCREAMING_SNAKE_CASE     =       """lower newer"""
										return input_text, output_text





							def  _UpperCAmelCase  (       self							:						Optional[Any]      )      ->       Union[str, Any]:
										SCREAMING_SNAKE_CASE     =       self.tokenizer_class(vocab_file=self.vocab_file							,  merges_file=self.merges_file      )

										SCREAMING_SNAKE_CASE     =       """lower"""
										SCREAMING_SNAKE_CASE     =       ["""low""", """er</w>"""]
										SCREAMING_SNAKE_CASE     =       tokenizer.tokenize(a      )
										self.assertListEqual(a							,  a      )

										SCREAMING_SNAKE_CASE     =       tokens + ["""<unk>"""]
										SCREAMING_SNAKE_CASE     =       [16, 17, 23]
										self.assertListEqual(tokenizer.convert_tokens_to_ids(a      )							,  a      )





							def  _UpperCAmelCase  (       self							:						str      )      ->       Union[str, Any]:
										if not self.test_rust_tokenizer:
													return

										SCREAMING_SNAKE_CASE     =       self.get_tokenizer()
										SCREAMING_SNAKE_CASE     =       self.get_rust_tokenizer()

										SCREAMING_SNAKE_CASE     =       """lower,newer"""

										SCREAMING_SNAKE_CASE     =       tokenizer.tokenize(a      )
										SCREAMING_SNAKE_CASE     =       rust_tokenizer.tokenize(a      )
										self.assertListEqual(a							,  a      )

										SCREAMING_SNAKE_CASE     =       tokenizer.encode(a							,  add_special_tokens=a      )
										SCREAMING_SNAKE_CASE     =       rust_tokenizer.encode(a							,  add_special_tokens=a      )
										self.assertListEqual(a							,  a      )

										SCREAMING_SNAKE_CASE     =       self.get_rust_tokenizer()
										SCREAMING_SNAKE_CASE     =       tokenizer.encode(a      )
										SCREAMING_SNAKE_CASE     =       rust_tokenizer.encode(a      )
										self.assertListEqual(a							,  a      )







							@slow
							def  _UpperCAmelCase  (       self							:						Union[str, Any]      )      ->       Optional[int]:
										SCREAMING_SNAKE_CASE     =       self.tokenizer_class.from_pretrained("""allegro/herbert-base-cased"""      )

										SCREAMING_SNAKE_CASE     =       tokenizer.encode("""konstruowanie sekwencji"""							,  add_special_tokens=a      )
										SCREAMING_SNAKE_CASE     =       tokenizer.encode("""konstruowanie wielu sekwencji"""							,  add_special_tokens=a      )

										SCREAMING_SNAKE_CASE     =       tokenizer.build_inputs_with_special_tokens(a      )
										SCREAMING_SNAKE_CASE     =       tokenizer.build_inputs_with_special_tokens(a							,  a      )

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












def        lowerCamelCase_     (     SCREAMING_SNAKE_CASE       ,						SCREAMING_SNAKE_CASE ):
			'''simple docstring'''
			if n == 0:
						return 1

			elif n % 2 == 1:
						return binary_exponentiation(SCREAMING_SNAKE_CASE       ,						n - 1 ) * a

			else:
						SCREAMING_SNAKE_CASE     =       binary_exponentiation(SCREAMING_SNAKE_CASE       ,						n / 2 )
						return b * b


if __name__ == "__main__":
		try:
				__A    :				Tuple    						=	int(input("""Enter Base : """).strip())
				__A    :				Any    						=	int(input("""Enter Power : """).strip())
		except ValueError:
				print("""Invalid literal for integer""")

		__A    :				Union[str, Any]    						=	binary_exponentiation(BASE, POWER)
		print(f'''{BASE}^({POWER}) : {RESULT}''')






