


import os
from shutil import copyfile
from typing import Any, Dict, List, Optional, Tuple

import sentencepiece as spm

from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from ...utils import logging


lowerCAmelCase			=				logging.get_logger(__name__)

lowerCAmelCase			=				'▁'

lowerCAmelCase			=				{'vocab_file': 'sentencepiece.bpe.model', 'monolingual_vocab_file': 'dict.txt'}

lowerCAmelCase			=				{
    'vocab_file': {
        'vinai/bartpho-syllable': 'https://huggingface.co/vinai/bartpho-syllable/resolve/main/sentencepiece.bpe.model',
    },
    'monolingual_vocab_file': {
        'vinai/bartpho-syllable': 'https://huggingface.co/vinai/bartpho-syllable/resolve/main/dict.txt',
    },
}

lowerCAmelCase			=				{'vinai/bartpho-syllable': 1024}


class 			_a				(     UpperCamelCase__     ):
							_lowercase      :     Tuple     =					VOCAB_FILES_NAMES
							_lowercase      :     Dict     =					PRETRAINED_VOCAB_FILES_MAP
							_lowercase      :     Optional[int]     =					PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
							_lowercase      :     Any     =					['''input_ids''', '''attention_mask''']

							def __init__(				self:      Optional[int]       ,		UpperCamelCase_:      Dict       ,		UpperCamelCase_:      Optional[int]       ,		UpperCamelCase_:      Optional[Any]="<s>"       ,		UpperCamelCase_:      List[Any]="</s>"       ,		UpperCamelCase_:      Optional[int]="</s>"       ,		UpperCamelCase_:      List[str]="<s>"       ,		UpperCamelCase_:      Optional[int]="<unk>"       ,		UpperCamelCase_:      Optional[int]="<pad>"       ,		UpperCamelCase_:      Optional[int]="<mask>"       ,		UpperCamelCase_:      Optional[Dict[str, Any]] = None       ,		**UpperCamelCase_:      int       ,		)     ->  None:





									"""simple docstring"""







									lowercase__				= AddedToken(UpperCamelCase_       ,		lstrip=UpperCamelCase_       ,		rstrip=UpperCamelCase_				) if isinstance(UpperCamelCase_       ,		UpperCamelCase_				) else mask_token

									lowercase__				= {} if sp_model_kwargs is None else sp_model_kwargs

									super().__init__(
									    bos_token=UpperCamelCase_       ,		eos_token=UpperCamelCase_       ,		unk_token=UpperCamelCase_       ,		sep_token=UpperCamelCase_       ,		cls_token=UpperCamelCase_       ,		pad_token=UpperCamelCase_       ,		mask_token=UpperCamelCase_       ,		sp_model_kwargs=self.sp_model_kwargs       ,		**UpperCamelCase_       ,		)

									lowercase__				= vocab_file
									lowercase__				= monolingual_vocab_file
									lowercase__				= spm.SentencePieceProcessor(**self.sp_model_kwargs				)
									self.sp_model.Load(str(UpperCamelCase_				)				)

									# Load the reduced vocab

									# Keep order of special tokens for backward compatibility
									lowercase__				= {}
									lowercase__				= 0
									for token in [bos_token, pad_token, eos_token, unk_token, sep_token, cls_token]:
											if str(UpperCamelCase_				) not in self.fairseq_tokens_to_ids:
													lowercase__				= cnt
													cnt += 1
									with open(UpperCamelCase_       ,		'''r'''       ,		encoding='''utf-8'''				) as f:
											for line in f.readlines():
													lowercase__				= line.strip().split()[0]
													lowercase__				= len(self.fairseq_tokens_to_ids				)
									if str(UpperCamelCase_				) not in self.fairseq_tokens_to_ids:
											lowercase__				= len(self.fairseq_tokens_to_ids				)

									lowercase__				= {v: k for k, v in self.fairseq_tokens_to_ids.items()}

							def __getstate__(				self:      Tuple				)     ->  int:





									"""simple docstring"""







									lowercase__				= self.__dict__.copy()
									lowercase__				= None
									lowercase__				= self.sp_model.serialized_model_proto()
									return state

							def __setstate__(				self:      List[str]       ,		UpperCamelCase_:      int				)     ->  List[Any]:





									"""simple docstring"""







									lowercase__				= d

									# for backward compatibility
									if not hasattr(self       ,		'''sp_model_kwargs'''				):
											lowercase__				= {}

									lowercase__				= spm.SentencePieceProcessor(**self.sp_model_kwargs				)
									self.sp_model.LoadFromSerializedProto(self.sp_model_proto				)

							def  lowerCamelCase_					(				self:      Optional[Any]       ,		UpperCamelCase_:      List[int]       ,		UpperCamelCase_:      Optional[List[int]] = None				)     ->  List[int]:





									"""simple docstring"""







									if token_ids_a is None:
											return [self.cls_token_id] + token_ids_a + [self.sep_token_id]
									lowercase__				= [self.cls_token_id]
									lowercase__				= [self.sep_token_id]
									return cls + token_ids_a + sep + sep + token_ids_a + sep

							def  lowerCamelCase_					(				self:      Union[str, Any]       ,		UpperCamelCase_:      List[int]       ,		UpperCamelCase_:      Optional[List[int]] = None       ,		UpperCamelCase_:      bool = False				)     ->  List[int]:





									"""simple docstring"""







									if already_has_special_tokens:
											return super().get_special_tokens_mask(
											    token_ids_a=UpperCamelCase_       ,		token_ids_a=UpperCamelCase_       ,		already_has_special_tokens=UpperCamelCase_				)

									if token_ids_a is None:
											return [1] + ([0] * len(UpperCamelCase_				)) + [1]
									return [1] + ([0] * len(UpperCamelCase_				)) + [1, 1] + ([0] * len(UpperCamelCase_				)) + [1]

							def  lowerCamelCase_					(				self:      List[Any]       ,		UpperCamelCase_:      List[int]       ,		UpperCamelCase_:      Optional[List[int]] = None				)     ->  List[int]:





									"""simple docstring"""







									lowercase__				= [self.sep_token_id]
									lowercase__				= [self.cls_token_id]

									if token_ids_a is None:
											return len(cls + token_ids_a + sep				) * [0]
									return len(cls + token_ids_a + sep + sep + token_ids_a + sep				) * [0]

							@property
							def  lowerCamelCase_					(				self:      List[str]				)     ->  List[str]:





									"""simple docstring"""







									return len(self.fairseq_ids_to_tokens				)

							def  lowerCamelCase_					(				self:      Union[str, Any]				)     ->  List[str]:





									"""simple docstring"""







									lowercase__				= {self.convert_ids_to_tokens(UpperCamelCase_				): i for i in range(self.vocab_size				)}
									vocab.update(self.added_tokens_encoder				)
									return vocab

							def  lowerCamelCase_					(				self:      int       ,		UpperCamelCase_:      str				)     ->  List[str]:





									"""simple docstring"""







									return self.sp_model.encode(UpperCamelCase_       ,		out_type=UpperCamelCase_				)

							def  lowerCamelCase_					(				self:      Optional[int]       ,		UpperCamelCase_:      Any				)     ->  Dict:





									"""simple docstring"""







									if token in self.fairseq_tokens_to_ids:
											return self.fairseq_tokens_to_ids[token]
									else:
											return self.unk_token_id

							def  lowerCamelCase_					(				self:      str       ,		UpperCamelCase_:      Union[str, Any]				)     ->  Union[str, Any]:





									"""simple docstring"""







									return self.fairseq_ids_to_tokens[index]

							def  lowerCamelCase_					(				self:      Optional[Any]       ,		UpperCamelCase_:      int				)     ->  Dict:





									"""simple docstring"""







									lowercase__				= ''''''.join(UpperCamelCase_				).replace(UpperCamelCase_       ,		''' '''				).strip()
									return out_string


							def  lowerCamelCase_					(				self:      Any       ,		UpperCamelCase_:      str       ,		UpperCamelCase_:      Optional[str] = None				)     ->  Tuple[str]:





									"""simple docstring"""







									if not os.path.isdir(UpperCamelCase_				):
											logger.error(f'Vocabulary path ({save_directory}) should be a directory'				)
											return
									lowercase__				= os.path.join(
									    UpperCamelCase_       ,		(filename_prefix + '''-''' if filename_prefix else '''''') + VOCAB_FILES_NAMES['''vocab_file''']				)
									lowercase__				= os.path.join(
									    UpperCamelCase_       ,		(filename_prefix + '''-''' if filename_prefix else '''''') + VOCAB_FILES_NAMES['''monolingual_vocab_file''']       ,		)

									if os.path.abspath(self.vocab_file				) != os.path.abspath(UpperCamelCase_				) and os.path.isfile(self.vocab_file				):
											copyfile(self.vocab_file       ,		UpperCamelCase_				)
									elif not os.path.isfile(self.vocab_file				):
											with open(UpperCamelCase_       ,		'''wb'''				) as fi:
													lowercase__				= self.sp_model.serialized_model_proto()
													fi.write(UpperCamelCase_				)

									if os.path.abspath(self.monolingual_vocab_file				) != os.path.abspath(
									    UpperCamelCase_				) and os.path.isfile(self.monolingual_vocab_file				):
											copyfile(self.monolingual_vocab_file       ,		UpperCamelCase_				)
									elif not os.path.isfile(self.monolingual_vocab_file				):
											with open(UpperCamelCase_       ,		'''w'''       ,		encoding='''utf-8'''				) as fp:
													for token in self.fairseq_tokens_to_ids:
															if token not in self.all_special_tokens:
																	fp.write(f'{str(UpperCamelCase_				)} \n'				)

									return out_vocab_file, out_monolingual_vocab_file






def 	__lowerCamelCase						(							lowerCamelCase__		:						int      ):





			'''simple docstring'''




			lowerCamelCase    		=  (1 + 24 * n) ** 0.5
			return ((1 + root) / 6) % 1 == 0






def 	__lowerCamelCase						(							lowerCamelCase__		:						int = 5000      ):





			'''simple docstring'''




			lowerCamelCase    		=  [(i * (3 * i - 1)) // 2 for i in range(1  ,							lowerCamelCase__      )]
			for i, pentagonal_i in enumerate(lowerCamelCase__      ):
						for j in range(lowerCamelCase__  ,							len(lowerCamelCase__      )      ):
									lowerCamelCase    		=  pentagonal_nums[j]
									lowerCamelCase    		=  pentagonal_i + pentagonal_j
									lowerCamelCase    		=  pentagonal_j - pentagonal_i
									if is_pentagonal(lowerCamelCase__      ) and is_pentagonal(lowerCamelCase__      ):
												return b

			return -1


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

