





'''simple docstring'''






import os
import unittest

from transformers.models.bartpho.tokenization_bartpho import VOCAB_FILES_NAMES, BartphoTokenizer
from transformers.testing_utils import get_tests_dir

from ...test_tokenization_common import TokenizerTesterMixin


lowerCAmelCase									=   get_tests_dir("""fixtures/test_sentencepiece_bpe.model""")
class 		lowerCamelCase	(   _A   , unittest.TestCase							):
	snake_case_   = BartphoTokenizer
	snake_case_   = False
	snake_case_   = True



	def 	_lowerCamelCase     ( self						):
			super().setUp()

			lowerCAmelCase  :     Optional[int]       						= ["▁This", "▁is", "▁a", "▁t", "est"]
			lowerCAmelCase  :     Any       						= dict(zip(a_		,   range(len(a_						)						)						)						)
			lowerCAmelCase  :     Any       						= {"unk_token": "<unk>"}

			lowerCAmelCase  :     Tuple       						= os.path.join(self.tmpdirname		,   VOCAB_FILES_NAMES["monolingual_vocab_file"]						)
			with open(self.monolingual_vocab_file		,   "w"		,   encoding="utf-8"						) as fp:
					for token in vocab_tokens:
							fp.write(F'''{token} {vocab_tokens[token]}\n'''						)

			lowerCAmelCase  :     List[str]       						= BartphoTokenizer(a_		,   self.monolingual_vocab_file		,   **self.special_tokens_map						)
			tokenizer.save_pretrained(self.tmpdirname						)



	def 	_lowerCamelCase     ( self		,   **a_						):
			kwargs.update(self.special_tokens_map						)
			return BartphoTokenizer.from_pretrained(self.tmpdirname		,   **a_						)



	def 	_lowerCamelCase     ( self		,   a_						):
			lowerCAmelCase  :     List[Any]       						= "This is a là test"
			lowerCAmelCase  :     Union[str, Any]       						= "This is a<unk><unk> test"
			return input_text, output_text





	def 	_lowerCamelCase     ( self						):
			lowerCAmelCase  :     List[str]       						= BartphoTokenizer(a_		,   self.monolingual_vocab_file		,   **self.special_tokens_map						)
			lowerCAmelCase  :     Dict       						= "This is a là test"
			lowerCAmelCase  :     int       						= "▁This ▁is ▁a ▁l à ▁t est".split()
			lowerCAmelCase  :     int       						= tokenizer.tokenize(a_						)
			self.assertListEqual(a_		,   a_						)

			lowerCAmelCase  :     Tuple       						= tokens + [tokenizer.unk_token]
			lowerCAmelCase  :     Dict       						= [4, 5, 6, 3, 3, 7, 8, 3]
			self.assertListEqual(tokenizer.convert_tokens_to_ids(a_						)		,   a_						)










'''simple docstring'''






lowerCAmelCase									=   [sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(10_00_00)]






def   __A    (				a_    :	int						):
		lowerCAmelCase  :     Optional[int]       						= 0
		while number:
				# Increased Speed Slightly by checking every 5 digits together.
				sum_of_digits_squared += DIGITS_SQUARED[number % 1_0_0_0_0_0]
				number //= 1_0_0_0_0_0

		return sum_of_digits_squared


# There are 2 Chains made,
# One ends with 89 with the chain member 58 being the one which when declared first,
# there will be the least number of iterations for all the members to be checked.

# The other one ends with 1 and has only one element 1.

# So 58 and 1 are chosen to be declared at the starting.

# Changed dictionary to an array to quicken the solution
lowerCAmelCase									=   [None] * 10_00_00_00
lowerCAmelCase									=   True
lowerCAmelCase									=   False






def   __A    (				a_    :	int						):

		if CHAINS[number - 1] is not None:
				return CHAINS[number - 1]  # type: ignore

		lowerCAmelCase  :     Dict       						= chain(next_number(a_						)						)
		lowerCAmelCase  :     Union[str, Any]       						= number_chain

		while number < 1_0_0_0_0_0_0_0:
				lowerCAmelCase  :     Any       						= number_chain
				number *= 1_0

		return number_chain






def   __A    (				a_    :	int = 1_0_0_0_0_0_0_0						):
		for i in range(1   ,a_						):
				if CHAINS[i] is None:
						chain(i + 1						)

		return CHAINS[:number].count(a_						)


if __name__ == "__main__":
					import doctest

					doctest.testmod()
					print(F'''{solution() = }''')



