
'''simple docstring'''


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_ :  Optional[int]     =					{'vocab_file': 'vocab.txt', 'tokenizer_file': 'tokenizer.json'}

snake_case_ :  Dict     =					{
    '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_ :  List[Any]     =					{
    'unc-nlp/lxmert-base-uncased': 512,
}

snake_case_ :  List[str]     =					{
    'unc-nlp/lxmert-base-uncased': {'do_lower_case': True},
}


class 						lowercase__	(  snake_case_   ):






   '''simple docstring'''







   _snake_case		   =							VOCAB_FILES_NAMES
   _snake_case		   =							PRETRAINED_VOCAB_FILES_MAP
   _snake_case		   =							PRETRAINED_INIT_CONFIGURATION
   _snake_case		   =							PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
   _snake_case		   =							LxmertTokenizer







   def __init__(			self ,   lowerCamelCase__=None ,   lowerCamelCase__=None ,   lowerCamelCase__=True ,   lowerCamelCase__="[UNK]" ,   lowerCamelCase__="[SEP]" ,   lowerCamelCase__="[PAD]" ,   lowerCamelCase__="[CLS]" ,   lowerCamelCase__="[MASK]" ,   lowerCamelCase__=True ,   lowerCamelCase__=None ,   **lowerCamelCase__ ,   ):

      '''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 ,   lowerCamelCase__ ,   lowerCamelCase__=None   ):

      '''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 ,   lowerCamelCase__ ,   lowerCamelCase__ = None   ):

      '''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 ,   lowerCamelCase__ ,   lowerCamelCase__ = None   ):

      '''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_flax_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


snake_case_ :  Any     =					{
    'configuration_electra': ['ELECTRA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ElectraConfig', 'ElectraOnnxConfig'],
    'tokenization_electra': ['ElectraTokenizer'],
}

try:
   if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   snake_case_ :  Union[str, Any]     =					['ElectraTokenizerFast']

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   snake_case_ :  Tuple     =					[
       'ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST',
       'ElectraForCausalLM',
       'ElectraForMaskedLM',
       'ElectraForMultipleChoice',
       'ElectraForPreTraining',
       'ElectraForQuestionAnswering',
       'ElectraForSequenceClassification',
       'ElectraForTokenClassification',
       'ElectraModel',
       'ElectraPreTrainedModel',
       'load_tf_weights_in_electra',
   ]

try:
   if not is_tf_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   snake_case_ :  int     =					[
       'TF_ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST',
       'TFElectraForMaskedLM',
       'TFElectraForMultipleChoice',
       'TFElectraForPreTraining',
       'TFElectraForQuestionAnswering',
       'TFElectraForSequenceClassification',
       'TFElectraForTokenClassification',
       'TFElectraModel',
       'TFElectraPreTrainedModel',
   ]

try:
   if not is_flax_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   snake_case_ :  Optional[int]     =					[
       'FlaxElectraForCausalLM',
       'FlaxElectraForMaskedLM',
       'FlaxElectraForMultipleChoice',
       'FlaxElectraForPreTraining',
       'FlaxElectraForQuestionAnswering',
       'FlaxElectraForSequenceClassification',
       'FlaxElectraForTokenClassification',
       'FlaxElectraModel',
       'FlaxElectraPreTrainedModel',
   ]


if TYPE_CHECKING:
   from .configuration_electra import ELECTRA_PRETRAINED_CONFIG_ARCHIVE_MAP, ElectraConfig, ElectraOnnxConfig
   from .tokenization_electra import ElectraTokenizer

   try:
      if not is_tokenizers_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .tokenization_electra_fast import ElectraTokenizerFast

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_electra import (
          ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST,
          ElectraForCausalLM,
          ElectraForMaskedLM,
          ElectraForMultipleChoice,
          ElectraForPreTraining,
          ElectraForQuestionAnswering,
          ElectraForSequenceClassification,
          ElectraForTokenClassification,
          ElectraModel,
          ElectraPreTrainedModel,
          load_tf_weights_in_electra,
      )

   try:
      if not is_tf_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_tf_electra import (
          TF_ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST,
          TFElectraForMaskedLM,
          TFElectraForMultipleChoice,
          TFElectraForPreTraining,
          TFElectraForQuestionAnswering,
          TFElectraForSequenceClassification,
          TFElectraForTokenClassification,
          TFElectraModel,
          TFElectraPreTrainedModel,
      )

   try:
      if not is_flax_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_flax_electra import (
          FlaxElectraForCausalLM,
          FlaxElectraForMaskedLM,
          FlaxElectraForMultipleChoice,
          FlaxElectraForPreTraining,
          FlaxElectraForQuestionAnswering,
          FlaxElectraForSequenceClassification,
          FlaxElectraForTokenClassification,
          FlaxElectraModel,
          FlaxElectraPreTrainedModel,
      )

else:
   import sys

   snake_case_ :  Union[str, Any]     =					_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)





