


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			: Optional[Any]				   =					"src/transformers"


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

SCREAMING_SNAKE_CASE			: Tuple				   =					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			: str				   =					re.compile("\[(.+?)\]\((https://huggingface\.co/.+?)\)")


SCREAMING_SNAKE_CASE			: Dict				   =					{
    "CLIPConfigMixin",
    "DecisionTransformerConfigMixin",
    "EncoderDecoderConfigMixin",
    "RagConfigMixin",
    "SpeechEncoderDecoderConfigMixin",
    "VisionEncoderDecoderConfigMixin",
    "VisionTextDualEncoderConfigMixin",
}



def 							UpperCamelCase_( )       ->		List[Any]:
    _lowercase			:				Optional[Any] 						=						[]

    for config_class in list(CONFIG_MAPPING.values()					):
        _lowercase			:				Any 						=						False

        # source code of `config_class`
        _lowercase			:				str 						=						inspect.getsource(lowerCamelCase_					)
        _lowercase			:				Optional[Any] 						=						_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')`
            _lowercase						,							_lowercase			:				List[str] 						=						checkpoint

            # verify the checkpoint name corresponds to the checkpoint link
            _lowercase			:				Union[str, Any] 						=						F'''https://huggingface.co/{ckpt_name}'''
            if ckpt_link == ckpt_link_from_name:
                _lowercase			:				List[Any] 						=						True
                break

        _lowercase			:				List[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:
        _lowercase			:				Union[str, Any] 						=						'\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()






from typing import TYPE_CHECKING

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


SCREAMING_SNAKE_CASE			: str				   =					{
    "configuration_gpt_bigcode": ["GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTBigCodeConfig"],
}

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 SCREAMING_SNAKE_CASE			: int				   =					[
     "GPT_BIGCODE_PRETRAINED_MODEL_ARCHIVE_LIST",
     "GPTBigCodeForSequenceClassification",
     "GPTBigCodeForTokenClassification",
     "GPTBigCodeForCausalLM",
     "GPTBigCodeModel",
     "GPTBigCodePreTrainedModel",
 ]

if TYPE_CHECKING:
 from .configuration_gpt_bigcode import GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP, GPTBigCodeConfig

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_gpt_bigcode import (
      GPT_BIGCODE_PRETRAINED_MODEL_ARCHIVE_LIST,
      GPTBigCodeForCausalLM,
      GPTBigCodeForSequenceClassification,
      GPTBigCodeForTokenClassification,
      GPTBigCodeModel,
      GPTBigCodePreTrainedModel,
  )


else:
 import sys

 SCREAMING_SNAKE_CASE			: List[Any]				   =					_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)


