






import json
import os
from typing import Optional, Tuple

from ...tokenization_utils import PreTrainedTokenizer
from ...utils import logging


UpperCAmelCase_ :						List[Any]      =      logging.get_logger(__name__)

UpperCAmelCase_ :						Any      =      {'''vocab_file''': '''vocab.json'''}

UpperCAmelCase_ :						Union[str, Any]      =      {
    '''vocab_file''': {
        '''mgp-str''': '''https://huggingface.co/alibaba-damo/mgp-str-base/blob/main/vocab.json''',
    }
}

UpperCAmelCase_ :						Dict      =      {'''mgp-str''': 27}

class     _SCREAMING_SNAKE_CASE       (			_a      ):
	snake_case__							:     Optional[Any]     	=  VOCAB_FILES_NAMES
	snake_case__							:     Optional[int]     	=  PRETRAINED_VOCAB_FILES_MAP
	snake_case__							:     Optional[int]     	=  PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES





	def __init__(		self				:					List[str] ,  __lowerCamelCase				:					str ,  __lowerCamelCase				:					int="[GO]" ,  __lowerCamelCase				:					Union[str, Any]="[GO]" ,  __lowerCamelCase				:					Tuple="[s]" ,  __lowerCamelCase				:					Any="[GO]" ,  **__lowerCamelCase				:					Optional[int]	):
		super().__init__(
		    unk_token=__lowerCamelCase ,  bos_token=__lowerCamelCase ,  eos_token=__lowerCamelCase ,  pad_token=__lowerCamelCase ,  **__lowerCamelCase ,  )

		with open(__lowerCamelCase ,  encoding="""utf-8"""	) as vocab_handle:
			UpperCamelCase     :Tuple          =	json.load(__lowerCamelCase	)
		UpperCamelCase     :int          =	{v: k for k, v in self.vocab.items()}





	@property
	def 						_A (		self				:					Optional[Any]	):
		return len(self.vocab	)





	def 						_A (		self				:					int	):
		return dict(self.vocab ,  **self.added_tokens_encoder	)





	def 						_A (		self				:					Union[str, Any] ,  __lowerCamelCase				:					Tuple	):
		UpperCamelCase     :List[Any]          =	[]
		for s in text:
			char_tokens.extend(__lowerCamelCase	)
		return char_tokens





	def 						_A (		self				:					int ,  __lowerCamelCase				:					List[Any]	):
		return self.vocab.get(__lowerCamelCase ,  self.vocab.get(self.unk_token	)	)





	def 						_A (		self				:					str ,  __lowerCamelCase				:					List[Any]	):
		return self.decoder.get(__lowerCamelCase	)





	def 						_A (		self				:					Tuple ,  __lowerCamelCase				:					str ,  __lowerCamelCase				:					Optional[str] = None	):
		if not os.path.isdir(__lowerCamelCase	):
			logger.error("""Vocabulary path ({}) should be a directory""".format(__lowerCamelCase	)	)
			return
		UpperCamelCase     :List[str]          =	os.path.join(
		    __lowerCamelCase ,  (filename_prefix + """-""" if filename_prefix else """""") + VOCAB_FILES_NAMES["""vocab_file"""]	)

		with open(__lowerCamelCase ,  """w""" ,  encoding="""utf-8"""	) as f:
			f.write(json.dumps(self.vocab ,  indent=2 ,  sort_keys=__lowerCamelCase ,  ensure_ascii=__lowerCamelCase	) + """\n"""	)

		return (vocab_file,)






"""simple docstring"""


from math import factorial

A_						=				{str(d): factorial(d) for d in range(10)}


def 					UpperCAmelCase__       (snake_case__							:					int    ):
  """simple docstring"""

  return sum(DIGIT_FACTORIAL[d] for d in str(snake_case__    )    )


def 					UpperCAmelCase__       ():
  """simple docstring"""

  _snake_case							:		List[str]								=  7 * factorial(9    ) + 1
  return sum(i for i in range(3		,   snake_case__    ) if sum_of_digit_factorial(snake_case__    ) == i    )


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


