




import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from .tokenization_lxmert import LxmertTokenizer


snake_case__			:    Union[str, Any]			     =      {'''vocab_file''': '''vocab.txt''', '''tokenizer_file''': '''tokenizer.json'''}

snake_case__			:    str			     =      {
    '''vocab_file''': {
        '''unc-nlp/lxmert-base-uncased''': '''https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/vocab.txt''',
    },
    '''tokenizer_file''': {
        '''unc-nlp/lxmert-base-uncased''': (
            '''https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/tokenizer.json'''
        ),
    },
}

snake_case__			:    int			     =      {
    '''unc-nlp/lxmert-base-uncased''': 5_1_2,
}

snake_case__			:    Tuple			     =      {
    '''unc-nlp/lxmert-base-uncased''': {'''do_lower_case''': True},
}





class      snake_case	(						UpperCAmelCase__				):


   '''simple docstring'''







   UpperCamelCase__						:							List[str] 	=   VOCAB_FILES_NAMES
   UpperCamelCase__						:							Optional[int] 	=   PRETRAINED_VOCAB_FILES_MAP
   UpperCamelCase__						:							List[str] 	=   PRETRAINED_INIT_CONFIGURATION
   UpperCamelCase__						:							List[str] 	=   PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
   UpperCamelCase__						:							Dict 	=   LxmertTokenizer




   def __init__(       self  :						str    ,     lowerCamelCase_  :						Tuple=None    ,     lowerCamelCase_  :						Optional[Any]=None    ,     lowerCamelCase_  :						List[Any]=True    ,     lowerCamelCase_  :						Optional[int]="[UNK]"    ,     lowerCamelCase_  :						str="[SEP]"    ,     lowerCamelCase_  :						str="[PAD]"    ,     lowerCamelCase_  :						int="[CLS]"    ,     lowerCamelCase_  :						Optional[Any]="[MASK]"    ,     lowerCamelCase_  :						Optional[int]=True    ,     lowerCamelCase_  :						Any=None    ,     **lowerCamelCase_  :						Optional[Any]    ,     )       ->Tuple:
     '''simple docstring'''







     super().__init__(
         lowerCamelCase_    ,     tokenizer_file=lowerCamelCase_    ,     do_lower_case=lowerCamelCase_    ,     unk_token=lowerCamelCase_    ,     sep_token=lowerCamelCase_    ,     pad_token=lowerCamelCase_    ,     cls_token=lowerCamelCase_    ,     mask_token=lowerCamelCase_    ,     tokenize_chinese_chars=lowerCamelCase_    ,     strip_accents=lowerCamelCase_    ,     **lowerCamelCase_    ,     )

     UpperCAmelCase__         = json.loads(self.backend_tokenizer.normalizer.__getstate__()      )
     if (
         normalizer_state.get("""lowercase"""    ,     lowerCamelCase_      ) != do_lower_case
         or normalizer_state.get("""strip_accents"""    ,     lowerCamelCase_      ) != strip_accents
         or normalizer_state.get("""handle_chinese_chars"""    ,     lowerCamelCase_      ) != tokenize_chinese_chars
     ):
       UpperCAmelCase__         = getattr(lowerCamelCase_    ,     normalizer_state.pop("""type"""      )      )
       UpperCAmelCase__         = do_lower_case
       UpperCAmelCase__         = strip_accents
       UpperCAmelCase__         = tokenize_chinese_chars
       UpperCAmelCase__         = normalizer_class(**lowerCamelCase_      )

     UpperCAmelCase__         = do_lower_case




   def 						UpperCAmelCase							(       self  :						Optional[int]    ,     lowerCamelCase_  :						int    ,     lowerCamelCase_  :						List[Any]=None      )       ->Dict:
     '''simple docstring'''







     UpperCAmelCase__         = [self.cls_token_id] + token_ids_a + [self.sep_token_id]

     if token_ids_a:
       output += token_ids_a + [self.sep_token_id]

     return output




   def 						UpperCAmelCase							(       self  :						int    ,     lowerCamelCase_  :						List[int]    ,     lowerCamelCase_  :						Optional[List[int]] = None      )       ->List[Any]:
     '''simple docstring'''







     UpperCAmelCase__         = [self.sep_token_id]
     UpperCAmelCase__         = [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      ) * [0] + len(token_ids_a + sep      ) * [1]







   def 						UpperCAmelCase							(       self  :						List[Any]    ,     lowerCamelCase_  :						str    ,     lowerCamelCase_  :						Optional[str] = None      )       ->Tuple:
     '''simple docstring'''







     UpperCAmelCase__         = self._tokenizer.model.save(lowerCamelCase_    ,     name=lowerCamelCase_      )
     return tuple(lowerCamelCase_      )





'''simple docstring'''




from typing import TYPE_CHECKING

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


__UpperCAmelCase					={
    "configuration_mobilebert": [
        "MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP",
        "MobileBertConfig",
        "MobileBertOnnxConfig",
    ],
    "tokenization_mobilebert": ["MobileBertTokenizer"],
}

try:
  if not is_tokenizers_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  __UpperCAmelCase					=["MobileBertTokenizerFast"]

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  __UpperCAmelCase					=[
      "MOBILEBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
      "MobileBertForMaskedLM",
      "MobileBertForMultipleChoice",
      "MobileBertForNextSentencePrediction",
      "MobileBertForPreTraining",
      "MobileBertForQuestionAnswering",
      "MobileBertForSequenceClassification",
      "MobileBertForTokenClassification",
      "MobileBertLayer",
      "MobileBertModel",
      "MobileBertPreTrainedModel",
      "load_tf_weights_in_mobilebert",
  ]

try:
  if not is_tf_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  __UpperCAmelCase					=[
      "TF_MOBILEBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
      "TFMobileBertForMaskedLM",
      "TFMobileBertForMultipleChoice",
      "TFMobileBertForNextSentencePrediction",
      "TFMobileBertForPreTraining",
      "TFMobileBertForQuestionAnswering",
      "TFMobileBertForSequenceClassification",
      "TFMobileBertForTokenClassification",
      "TFMobileBertMainLayer",
      "TFMobileBertModel",
      "TFMobileBertPreTrainedModel",
  ]


if TYPE_CHECKING:
  from .configuration_mobilebert import (
      MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
      MobileBertConfig,
      MobileBertOnnxConfig,
  )
  from .tokenization_mobilebert import MobileBertTokenizer

  try:
    if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .tokenization_mobilebert_fast import MobileBertTokenizerFast

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_mobilebert import (
        MOBILEBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
        MobileBertForMaskedLM,
        MobileBertForMultipleChoice,
        MobileBertForNextSentencePrediction,
        MobileBertForPreTraining,
        MobileBertForQuestionAnswering,
        MobileBertForSequenceClassification,
        MobileBertForTokenClassification,
        MobileBertLayer,
        MobileBertModel,
        MobileBertPreTrainedModel,
        load_tf_weights_in_mobilebert,
    )

  try:
    if not is_tf_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_tf_mobilebert import (
        TF_MOBILEBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
        TFMobileBertForMaskedLM,
        TFMobileBertForMultipleChoice,
        TFMobileBertForNextSentencePrediction,
        TFMobileBertForPreTraining,
        TFMobileBertForQuestionAnswering,
        TFMobileBertForSequenceClassification,
        TFMobileBertForTokenClassification,
        TFMobileBertMainLayer,
        TFMobileBertModel,
        TFMobileBertPreTrainedModel,
    )

else:
  import sys

  __UpperCAmelCase					=_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
