"""simple docstring"""


import json
import os
from typing import Optional, Tuple

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


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

lowerCAmelCase_:					Optional[Any]     =					{"vocab_file": "vocab.json"}

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

lowerCAmelCase_:					List[Any]     =					{"mgp-str": 2_7}






class    a__    (   _a	):
   snake_case_							=      VOCAB_FILES_NAMES
   snake_case_							=      PRETRAINED_VOCAB_FILES_MAP
   snake_case_							=      PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES


   def __init__(     self,				_UpperCAmelCase,				_UpperCAmelCase="[GO]",				_UpperCAmelCase="[GO]",				_UpperCAmelCase="[s]",				_UpperCAmelCase="[GO]",				**_UpperCAmelCase  ):
        '''simple docstring'''



        super().__init__(
            unk_token=_UpperCAmelCase,				bos_token=_UpperCAmelCase,				eos_token=_UpperCAmelCase,				pad_token=_UpperCAmelCase,				**_UpperCAmelCase,				)

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


   @property
   def 	snake_case__	(     self  ):
        '''simple docstring'''



        return len(self.vocab  )


   def 	snake_case__	(     self  ):
        '''simple docstring'''



        return dict(self.vocab,				**self.added_tokens_encoder  )


   def 	snake_case__	(     self,				_UpperCAmelCase  ):
        '''simple docstring'''



        lowercase__				 =							[]
        for s in text:
             char_tokens.extend(_UpperCAmelCase  )
        return char_tokens


   def 	snake_case__	(     self,				_UpperCAmelCase  ):
        '''simple docstring'''



        return self.vocab.get(_UpperCAmelCase,				self.vocab.get(self.unk_token  )  )


   def 	snake_case__	(     self,				_UpperCAmelCase  ):
        '''simple docstring'''



        return self.decoder.get(_UpperCAmelCase  )


   def 	snake_case__	(     self,				_UpperCAmelCase,				_UpperCAmelCase = None  ):
        '''simple docstring'''



        if not os.path.isdir(_UpperCAmelCase  ):
             logger.error("Vocabulary path ({}) should be a directory".format(_UpperCAmelCase  )  )
             return
        lowercase__				 =							os.path.join(
            _UpperCAmelCase,				(filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["vocab_file"]  )

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

        return (vocab_file,)





"""simple docstring"""


from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


lowerCAmelCase_:					Union[str, Any]     =					{
    "configuration_distilbert": [
        "DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP",
        "DistilBertConfig",
        "DistilBertOnnxConfig",
    ],
    "tokenization_distilbert": ["DistilBertTokenizer"],
}

try:
 if not is_tokenizers_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCAmelCase_:					Union[str, Any]     =					["DistilBertTokenizerFast"]

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCAmelCase_:					Any     =					[
     "DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
     "DistilBertForMaskedLM",
     "DistilBertForMultipleChoice",
     "DistilBertForQuestionAnswering",
     "DistilBertForSequenceClassification",
     "DistilBertForTokenClassification",
     "DistilBertModel",
     "DistilBertPreTrainedModel",
 ]

try:
 if not is_tf_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCAmelCase_:					Tuple     =					[
     "TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
     "TFDistilBertForMaskedLM",
     "TFDistilBertForMultipleChoice",
     "TFDistilBertForQuestionAnswering",
     "TFDistilBertForSequenceClassification",
     "TFDistilBertForTokenClassification",
     "TFDistilBertMainLayer",
     "TFDistilBertModel",
     "TFDistilBertPreTrainedModel",
 ]

try:
 if not is_flax_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCAmelCase_:					Optional[Any]     =					[
     "FlaxDistilBertForMaskedLM",
     "FlaxDistilBertForMultipleChoice",
     "FlaxDistilBertForQuestionAnswering",
     "FlaxDistilBertForSequenceClassification",
     "FlaxDistilBertForTokenClassification",
     "FlaxDistilBertModel",
     "FlaxDistilBertPreTrainedModel",
 ]


if TYPE_CHECKING:
 from .configuration_distilbert import (
     DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
     DistilBertConfig,
     DistilBertOnnxConfig,
 )
 from .tokenization_distilbert import DistilBertTokenizer

 try:
  if not is_tokenizers_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .tokenization_distilbert_fast import DistilBertTokenizerFast

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_distilbert import (
      DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
      DistilBertForMaskedLM,
      DistilBertForMultipleChoice,
      DistilBertForQuestionAnswering,
      DistilBertForSequenceClassification,
      DistilBertForTokenClassification,
      DistilBertModel,
      DistilBertPreTrainedModel,
  )

 try:
  if not is_tf_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_tf_distilbert import (
      TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
      TFDistilBertForMaskedLM,
      TFDistilBertForMultipleChoice,
      TFDistilBertForQuestionAnswering,
      TFDistilBertForSequenceClassification,
      TFDistilBertForTokenClassification,
      TFDistilBertMainLayer,
      TFDistilBertModel,
      TFDistilBertPreTrainedModel,
  )

 try:
  if not is_flax_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_flax_distilbert import (
      FlaxDistilBertForMaskedLM,
      FlaxDistilBertForMultipleChoice,
      FlaxDistilBertForQuestionAnswering,
      FlaxDistilBertForSequenceClassification,
      FlaxDistilBertForTokenClassification,
      FlaxDistilBertModel,
      FlaxDistilBertPreTrainedModel,
  )

else:
 import sys

 lowerCAmelCase_:					Optional[int]     =					_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)




