





import importlib
import inspect
import os
import re


# All paths are set with the intent you should run this script from the root of the repo with the command
# python utils/check_config_docstrings.py
SCREAMING_SNAKE_CASE__       :			Dict			      =						"""src/transformers"""


# This is to make sure the transformers module imported is the one in the repo.
SCREAMING_SNAKE_CASE__       :			Dict			      =						importlib.util.spec_from_file_location(
    """transformers""",
    os.path.join(PATH_TO_TRANSFORMERS, """__init__.py"""),
    submodule_search_locations=[PATH_TO_TRANSFORMERS],
)
SCREAMING_SNAKE_CASE__       :			Optional[int]			      =						spec.loader.load_module()

SCREAMING_SNAKE_CASE__       :			str			      =						transformers.models.auto.configuration_auto.CONFIG_MAPPING

# Regex pattern used to find the checkpoint mentioned in the docstring of `config_class`.
# For example, `[bert-base-uncased](https://huggingface.co/bert-base-uncased)`
SCREAMING_SNAKE_CASE__       :			int			      =						re.compile("""\[(.+?)\]\((https://huggingface\.co/.+?)\)""")


SCREAMING_SNAKE_CASE__       :			List[str]			      =						{
    """CLIPConfigMixin""",
    """DecisionTransformerConfigMixin""",
    """EncoderDecoderConfigMixin""",
    """RagConfigMixin""",
    """SpeechEncoderDecoderConfigMixin""",
    """VisionEncoderDecoderConfigMixin""",
    """VisionTextDualEncoderConfigMixin""",
}






def       _A  (      ):
   a__	:						Dict      		=  []

   for config_class in list(CONFIG_MAPPING.values()   ):
      a__	:						Optional[Any]      		=  False

      # source code of `config_class`
      a__	:						Union[str, Any]      		=  inspect.getsource(lowerCamelCase   )
      a__	:						Tuple      		=  _re_checkpoint.findall(lowerCamelCase   )

      for checkpoint in checkpoints:
         # Each `checkpoint` is a tuple of a checkpoint name and a checkpoint link.
         # For example, `('bert-base-uncased', 'https://huggingface.co/bert-base-uncased')`
         a__		,     a__	:						Union[str, Any]      		=  checkpoint

         # verify the checkpoint name corresponds to the checkpoint link
         a__	:						Any      		=  F"""https://huggingface.co/{ckpt_name}"""
         if ckpt_link == ckpt_link_from_name:
            a__	:						Tuple      		=  True
            break

      a__	:						Union[str, Any]      		=  config_class.__name__
      if not checkpoint_found and name not in CONFIG_CLASSES_TO_IGNORE_FOR_DOCSTRING_CHECKPOINT_CHECK:
         configs_without_checkpoint.append(lowerCamelCase   )

   if len(lowerCamelCase   ) > 0:
      a__	:						Dict      		=  "\n".join(sorted(lowerCamelCase   )   )
      raise ValueError(F"""The following configurations don't contain any valid checkpoint:\n{message}"""   )


if __name__ == "__main__":
  check_config_docstrings_have_checkpoints()








import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

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


SCREAMING_SNAKE_CASE__       :			Optional[Any]			      =						{"""vocab_file""": """vocab.txt""", """tokenizer_file""": """tokenizer.json"""}

SCREAMING_SNAKE_CASE__       :			List[Any]			      =						{
    """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"""
        ),
    },
}

SCREAMING_SNAKE_CASE__       :			Any			      =						{
    """unc-nlp/lxmert-base-uncased""": 5_1_2,
}

SCREAMING_SNAKE_CASE__       :			Optional[int]			      =						{
    """unc-nlp/lxmert-base-uncased""": {"""do_lower_case""": True},
}







class   __lowerCAmelCase			(					_UpperCamelCase  ):
   _UpperCamelCase :						List[str]     		=				VOCAB_FILES_NAMES
   _UpperCamelCase :						str     		=				PRETRAINED_VOCAB_FILES_MAP
   _UpperCamelCase :						List[str]     		=				PRETRAINED_INIT_CONFIGURATION
   _UpperCamelCase :						Optional[int]     		=				PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
   _UpperCamelCase :						Optional[Any]     		=				LxmertTokenizer





   def __init__( self					,			snake_case=None					,			snake_case=None					,			snake_case=True					,			snake_case="[UNK]"					,			snake_case="[SEP]"					,			snake_case="[PAD]"					,			snake_case="[CLS]"					,			snake_case="[MASK]"					,			snake_case=True					,			snake_case=None					,			**snake_case					,			)				->  Any:
      """simple docstring"""





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

      a__	:						Optional[Any]      		=  json.loads(self.backend_tokenizer.normalizer.__getstate__()      )
      if (
          normalizer_state.get("lowercase"					,			snake_case      ) != do_lower_case
          or normalizer_state.get("strip_accents"					,			snake_case      ) != strip_accents
          or normalizer_state.get("handle_chinese_chars"					,			snake_case      ) != tokenize_chinese_chars
      ):
         a__	:						str      		=  getattr(snake_case					,			normalizer_state.pop("type"      )      )
         a__	:						Tuple      		=  do_lower_case
         a__	:						Union[str, Any]      		=  strip_accents
         a__	:						str      		=  tokenize_chinese_chars
         a__	:						List[str]      		=  normalizer_class(**snake_case      )

      a__	:						str      		=  do_lower_case





   def 	_snake_case ( self					,			snake_case					,			snake_case=None      )				->  List[str]:
      """simple docstring"""





      a__	:						Optional[int]      		=  [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 	_snake_case ( self					,			snake_case					,			snake_case = None      )				->  List[int]:
      """simple docstring"""





      a__	:						Tuple      		=  [self.sep_token_id]
      a__	:						str      		=  [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 	_snake_case ( self					,			snake_case					,			snake_case = None      )				->  Tuple[str]:
      """simple docstring"""





      a__	:						Optional[int]      		=  self._tokenizer.model.save(snake_case					,			name=snake_case      )
      return tuple(snake_case      )

