





import json
import os
from typing import Optional, Tuple

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


lowerCamelCase__          =    logging.get_logger(__name__)

lowerCamelCase__          =    {'''vocab_file''': '''vocab.json'''}

lowerCamelCase__          =    {
    '''vocab_file''': {
        '''mgp-str''': '''https://huggingface.co/alibaba-damo/mgp-str-base/blob/main/vocab.json''',
    }
}

lowerCamelCase__          =    {'''mgp-str''': 27}
class 	__magic_name__			(lowerCamelCase_ ):
					lowerCamelCase__     						=     VOCAB_FILES_NAMES
					lowerCamelCase__     						=     PRETRAINED_VOCAB_FILES_MAP
					lowerCamelCase__     						=     PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES




					def __init__(       self	,   _a	,   _a="[GO]"	,   _a="[GO]"	,   _a="[s]"	,   _a="[GO]"	,   **_a						)			->					Optional[Any]:
							super().__init__(
							    unk_token=snake_case__	,   bos_token=snake_case__	,   eos_token=snake_case__	,   pad_token=snake_case__	,   **snake_case__	,   )

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




					@property
					def 					__a     (       self						)			->					str:
							return len(self.vocab						)




					def 					__a     (       self						)			->					Optional[Any]:
							return dict(self.vocab	,   **self.added_tokens_encoder						)




					def 					__a     (       self	,   _a						)			->					Dict:
							lowerCAmelCase_												=				[]
							for s in text:
									char_tokens.extend(snake_case__						)
							return char_tokens




					def 					__a     (       self	,   _a						)			->					int:
							return self.vocab.get(snake_case__	,   self.vocab.get(self.unk_token						)						)




					def 					__a     (       self	,   _a						)			->					Optional[int]:
							return self.decoder.get(snake_case__						)




					def 					__a     (       self	,   _a	,   _a = None						)			->					Optional[int]:
							if not os.path.isdir(snake_case__						):
									logger.error("Vocabulary path ({}) should be a directory".format(snake_case__						)						)
									return
							lowerCAmelCase_												=				os.path.join(
							    snake_case__	,   (filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["vocab_file"]						)

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

							return (vocab_file,)







def        __UpperCAmelCase						(							lowerCamelCase_ :     str  )       ->  bool:







			"""simple docstring"""





			SCREAMING_SNAKE_CASE_   : Any					  =      0
			for ch in input_str:
						SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      ord(lowerCamelCase_  )
						SCREAMING_SNAKE_CASE_   : Tuple					  =      pow(2  ,							lowerCamelCase_  )

						# If we already turned on bit for current character's unicode
						if bitmap >> ch_unicode & 1 == 1:
									return False
						bitmap |= ch_bit_index_on
			return True


if __name__ == "__main__":
						import doctest

						doctest.testmod()



