





import logging
import os
from logging import (
    CRITICAL,  # NOQA
    DEBUG,  # NOQA
    ERROR,  # NOQA
    FATAL,  # NOQA
    INFO,  # NOQA
    NOTSET,  # NOQA
    WARN,  # NOQA
    WARNING,  # NOQA
)
from typing import Optional

from tqdm import auto as tqdm_lib


__A     =    {
    "debug": logging.DEBUG,
    "info": logging.INFO,
    "warning": logging.WARNING,
    "error": logging.ERROR,
    "critical": logging.CRITICAL,
}

__A     =    logging.WARNING





def 					lowerCAmelCase_			(	)					->		Optional[int]:







		"""simple docstring"""





		lowerCamelCase__:				Union[str, Any]        =os.getenv("DATASETS_VERBOSITY"     ,   __A		)
		if env_level_str:
				if env_level_str in log_levels:
						return log_levels[env_level_str]
				else:
						logging.getLogger().warning(
						    F"""Unknown option DATASETS_VERBOSITY={env_level_str}, """
						    F"""has to be one of: { ", ".join(log_levels.keys()		) }"""		)
		return _default_log_level





def 					lowerCAmelCase_			(	)					->		str:







		"""simple docstring"""





		return __name__.split("."		)[0]





def 					lowerCAmelCase_			(	)					->		logging.Logger:







		"""simple docstring"""





		return logging.getLogger(_get_library_name()		)





def 					lowerCAmelCase_			(	)					->		None:







		"""simple docstring"""





		lowerCamelCase__:				Tuple        =_get_library_root_logger()
		library_root_logger.setLevel(_get_default_logging_level()		)





def 					lowerCAmelCase_			(	)					->		None:







		"""simple docstring"""





		lowerCamelCase__:				Dict        =_get_library_root_logger()
		library_root_logger.setLevel(logging.NOTSET		)





def 					lowerCAmelCase_			(	__a = None		)					->		logging.Logger:







		"""simple docstring"""





		if name is None:
				lowerCamelCase__:				Dict        =_get_library_name()
		return logging.getLogger(__A		)





def 					lowerCAmelCase_			(	)					->		int:







		"""simple docstring"""





		return _get_library_root_logger().getEffectiveLevel()





def 					lowerCAmelCase_			(	__a		)					->		None:







		"""simple docstring"""





		_get_library_root_logger().setLevel(__A		)





def 					lowerCAmelCase_			(	)					->		Dict:







		"""simple docstring"""





		return set_verbosity(__A		)





def 					lowerCAmelCase_			(	)					->		Optional[int]:







		"""simple docstring"""





		return set_verbosity(__A		)





def 					lowerCAmelCase_			(	)					->		Optional[Any]:







		"""simple docstring"""





		return set_verbosity(__A		)





def 					lowerCAmelCase_			(	)					->		Optional[int]:







		"""simple docstring"""





		return set_verbosity(__A		)





def 					lowerCAmelCase_			(	)					->		None:







		"""simple docstring"""





		lowerCamelCase__:				Optional[Any]        =False





def 					lowerCAmelCase_			(	)					->		None:







		"""simple docstring"""





		lowerCamelCase__:				Any        =True


# Configure the library root logger at the module level (singleton-like)
_configure_library_root_logger()



class        _SCREAMING_SNAKE_CASE						:







	'''simple docstring'''

	def __init__(self    :       str	,			*UpperCAmelCase_    :       int	,			**UpperCAmelCase_    :       List[str])	->Union[str, Any]:  # pylint: disable=unused-argument



			'''simple docstring'''



			lowerCamelCase__:				str        =args[0] if args else None

	def __iter__(self    :       Optional[Any])	->Union[str, Any]:



			'''simple docstring'''



			return iter(self._iterator)

	def __getattr__(self    :       Any	,			UpperCAmelCase_    :       List[Any])	->List[str]:



			'''simple docstring'''



			def empty_fn(*UpperCAmelCase_    :       Any	,			**UpperCAmelCase_    :       Tuple):  # pylint: disable=unused-argument
					return

			return empty_fn

	def __enter__(self    :       Dict)	->List[str]:



			'''simple docstring'''



			return self







	def __exit__(self    :       List[Any]	,			UpperCAmelCase_    :       Dict	,			UpperCAmelCase_    :       int	,			UpperCAmelCase_    :       List[Any])	->Union[str, Any]:



			'''simple docstring'''



			return



__A     =    True



class        _SCREAMING_SNAKE_CASE						:







	'''simple docstring'''

	def __call__(self    :       int	,			*UpperCAmelCase_    :       str	,			UpperCAmelCase_    :       Tuple=False	,			**UpperCAmelCase_    :       Union[str, Any])	->Optional[int]:



			'''simple docstring'''



			if _tqdm_active and not disable:
					return tqdm_lib.tqdm(*_snake_case	,			**_snake_case)
			else:
					return EmptyTqdm(*_snake_case	,			**_snake_case)

	def 							SCREAMING_SNAKE_CASE_ (self    :       Tuple	,			*UpperCAmelCase_    :       Optional[Any]	,			**UpperCAmelCase_    :       Optional[int])	->Optional[Any]:



			'''simple docstring'''



			lowerCamelCase__:				Optional[Any]        =None
			if _tqdm_active:
					return tqdm_lib.tqdm.set_lock(*_snake_case	,			**_snake_case)







	def 							SCREAMING_SNAKE_CASE_ (self    :       List[str])	->List[str]:



			'''simple docstring'''



			if _tqdm_active:
					return tqdm_lib.tqdm.get_lock()



__A     =    _tqdm_cls()





def 					lowerCAmelCase_			(	)					->		bool:







		"""simple docstring"""





		global _tqdm_active
		return bool(_tqdm_active		)





def 					lowerCAmelCase_			(	)					->		int:







		"""simple docstring"""





		global _tqdm_active
		lowerCamelCase__:				Union[str, Any]        =True






def 					lowerCAmelCase_			(	)					->		Optional[int]:







		"""simple docstring"""





		global _tqdm_active
		lowerCamelCase__:				Union[str, Any]        =False








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


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

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


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





def 					lowerCAmelCase_			(	__a		)					->		Optional[int]:







  """simple docstring"""





  lowerCamelCase__:				List[Any]        =None

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

  # 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("/"		):
      lowerCamelCase__:				str        =ckpt_link[:-1]

    # verify the checkpoint name corresponds to the checkpoint link
    lowerCamelCase__:				Optional[int]        =F"""https://huggingface.co/{ckpt_name}"""
    if ckpt_link == ckpt_link_from_name:
      lowerCamelCase__:				List[Any]        =ckpt_name
      break

  return checkpoint





def 					lowerCAmelCase_			(	)					->		Tuple:







  """simple docstring"""





  lowerCamelCase__:				Union[str, Any]        =[]

  for config_class in list(CONFIG_MAPPING.values()		):
    # Skip deprecated models
    if "models.deprecated" in config_class.__module__:
      continue
    lowerCamelCase__:				List[Any]        =get_checkpoint_from_config_class(__a		)

    lowerCamelCase__:				Tuple        =config_class.__name__
    if checkpoint is None and name not in CONFIG_CLASSES_TO_IGNORE_FOR_DOCSTRING_CHECKPOINT_CHECK:
      configs_without_checkpoint.append(__a		)

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


if __name__ == "__main__":
     check_config_docstrings_have_checkpoints()

