



import json
from typing import Iterator, List, Union

from tokenizers import AddedToken, Regex, Tokenizer, decoders, normalizers, pre_tokenizers, trainers
from tokenizers.implementations.base_tokenizer import BaseTokenizer
from tokenizers.models import Unigram
from tokenizers.processors import TemplateProcessing







class 			__lowerCAmelCase    (			__lowerCamelCase						):



			def __init__(						self   :  Any ,		A   :  Tuple = "▁" ,		A   :  Dict = True ,		A   :  Optional[int] = "<unk>" ,		A   :  Union[str, Any] = "</s>" ,		A   :  List[str] = "<pad>" ,		)   ->    Tuple:



						"""simple docstring"""






						_UpperCAmelCase		       =   {
						    '''pad''': {'''id''': 0, '''token''': pad_token},
						    '''eos''': {'''id''': 1, '''token''': eos_token},
						    '''unk''': {'''id''': 2, '''token''': unk_token},
						}

						_UpperCAmelCase		       =   [None] * len(self.special_tokens)
						for token_dict in self.special_tokens.values():
									_UpperCAmelCase		       =   token_dict['''token''']

						_UpperCAmelCase		       =   Tokenizer(Unigram())

						_UpperCAmelCase		       =   normalizers.Sequence(
						    [
						        normalizers.Nmt(),
						        normalizers.NFKC(),
						        normalizers.Replace(Regex(' {2,}') ,		' '),
						        normalizers.Lowercase(),
						    ])
						_UpperCAmelCase		       =   pre_tokenizers.Sequence(
						    [
						        pre_tokenizers.Metaspace(replacement=A ,		add_prefix_space=A),
						        pre_tokenizers.Digits(individual_digits=A),
						        pre_tokenizers.Punctuation(),
						    ])
						_UpperCAmelCase		       =   decoders.Metaspace(replacement=A ,		add_prefix_space=A)

						_UpperCAmelCase		       =   TemplateProcessing(
						    single=F"$A {self.special_tokens['eos']['token']}" ,		special_tokens=[(self.special_tokens['eos']['token'], self.special_tokens['eos']['id'])] ,		)

						_UpperCAmelCase		       =   {
						    '''model''': '''SentencePieceUnigram''',
						    '''replacement''': replacement,
						    '''add_prefix_space''': add_prefix_space,
						}

						super().__init__(A ,		A)



			def     _lowerCamelCase       (						self   :  Union[str, Any] ,		A   :  List[Any] ,		A   :  Tuple = 80_00 ,		A   :  List[Any] = True ,		)   ->    Tuple:



						"""simple docstring"""






						_UpperCAmelCase		       =   trainers.UnigramTrainer(
						    vocab_size=A ,		special_tokens=self.special_tokens_list ,		show_progress=A ,		)

						if isinstance(A ,		A):
									_UpperCAmelCase		       =   [files]
						self._tokenizer.train(A ,		trainer=A)

						self.add_unk_id()



			def     _lowerCamelCase       (						self   :  Optional[Any] ,		A   :  Dict ,		A   :  Optional[int] = 80_00 ,		A   :  str = True ,		)   ->    Any:



						"""simple docstring"""






						_UpperCAmelCase		       =   trainers.UnigramTrainer(
						    vocab_size=A ,		special_tokens=self.special_tokens_list ,		show_progress=A ,		)

						self._tokenizer.train_from_iterator(A ,		trainer=A)

						self.add_unk_id()



			def     _lowerCamelCase       (						self   :  List[str])   ->    List[str]:



						"""simple docstring"""






						_UpperCAmelCase		       =   json.loads(self._tokenizer.to_str())

						_UpperCAmelCase		       =   self.special_tokens['''unk''']['''id''']

						_UpperCAmelCase		       =   Tokenizer.from_str(json.dumps(A))







def 		lowerCAmelCase_    (  __UpperCAmelCase:			int      )      ->	bool:
    return str(__UpperCAmelCase      ) == str(__UpperCAmelCase      )[::-1]




def 		lowerCAmelCase_    (  __UpperCAmelCase:			int      )      ->	int:
    return int(__UpperCAmelCase      ) + int(str(__UpperCAmelCase      )[::-1]      )




def 		lowerCAmelCase_    (  __UpperCAmelCase:			int = 1_0000      )      ->	int:
    UpperCamelCase__							:				Optional[Any]          =      []
    for num in range(1		,   __UpperCAmelCase      ):
        UpperCamelCase__							:				str          =      0
        UpperCamelCase__							:				Any          =      num
        while iterations < 50:
            UpperCamelCase__							:				List[Any]          =      sum_reverse(__UpperCAmelCase      )
            iterations += 1
            if is_palindrome(__UpperCAmelCase      ):
                break
        else:
            lychrel_nums.append(__UpperCAmelCase      )
    return len(__UpperCAmelCase      )


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

