

import inspect
import re

from transformers.utils import direct_transformers_import


# 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
lowerCAmelCase__								=		"""src/transformers"""


# This is to make sure the transformers module imported is the one in the repo.
lowerCAmelCase__								=		direct_transformers_import(PATH_TO_TRANSFORMERS)

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


lowerCAmelCase__								=		{
    """DecisionTransformerConfig""",
    """EncoderDecoderConfig""",
    """MusicgenConfig""",
    """RagConfig""",
    """SpeechEncoderDecoderConfig""",
    """TimmBackboneConfig""",
    """VisionEncoderDecoderConfig""",
    """VisionTextDualEncoderConfig""",
    """LlamaConfig""",
}






def 					lowerCamelCase_     (							UpperCAmelCase_							:     List[Any]	)						->				Optional[Any]:




	'''simple docstring'''




	_UpperCamelCase   :		List[str]			=						None

	# source code of `config_class`
	_UpperCamelCase   :		str			=						inspect.getsource(UpperCAmelCase_	)
	_UpperCamelCase   :		List[Any]			=						_re_checkpoint.findall(UpperCAmelCase_	)

	# Each `checkpoint` is a tuple of a checkpoint name and a checkpoint link.
	# For example, `('bert-base-uncased', 'https://huggingface.co/bert-base-uncased')`
	for ckpt_name, ckpt_link in checkpoints:
		# allow the link to end with `/`
		if ckpt_link.endswith('/'	):
			_UpperCamelCase   :		List[str]			=						ckpt_link[:-1]

		# verify the checkpoint name corresponds to the checkpoint link
		_UpperCamelCase   :		str			=						F'''https://huggingface.co/{ckpt_name}'''
		if ckpt_link == ckpt_link_from_name:
			_UpperCamelCase   :		Dict			=						ckpt_name
			break

	return checkpoint






def 					lowerCamelCase_     (							)						->				Dict:




	'''simple docstring'''




	_UpperCamelCase   :		int			=						[]

	for config_class in list(CONFIG_MAPPING.values()	):
		# Skip deprecated models
		if "models.deprecated" in config_class.__module__:
			continue
		_UpperCamelCase   :		Tuple			=						get_checkpoint_from_config_class(UpperCAmelCase_	)

		_UpperCamelCase   :		Optional[Any]			=						config_class.__name__
		if checkpoint is None and name not in CONFIG_CLASSES_TO_IGNORE_FOR_DOCSTRING_CHECKPOINT_CHECK:
			configs_without_checkpoint.append(UpperCAmelCase_	)

	if len(UpperCAmelCase_	) > 0:
		_UpperCamelCase   :		List[str]			=						'\n'.join(sorted(UpperCAmelCase_	)	)
		raise ValueError(F'''The following configurations don\'t contain any valid checkpoint:\n{message}'''	)


if __name__ == "__main__":
							check_config_docstrings_have_checkpoints()







from .glue import glue_convert_examples_to_features, glue_output_modes, glue_processors, glue_tasks_num_labels
from .squad import SquadExample, SquadFeatures, SquadVaProcessor, SquadVaProcessor, squad_convert_examples_to_features
from .utils import DataProcessor, InputExample, InputFeatures, SingleSentenceClassificationProcessor
from .xnli import xnli_output_modes, xnli_processors, xnli_tasks_num_labels




