





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 :    List[str]  							= '''src/transformers'''


# This is to make sure the transformers module imported is the one in the repo.
_lowerCamelCase :    List[str]  							= direct_transformers_import(PATH_TO_TRANSFORMERS)

_lowerCamelCase :    Union[str, Any]  							= 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 :    Optional[int]  							= re.compile(r'''\[(.+?)\]\((https://huggingface\.co/.+?)\)''')


_lowerCamelCase :    List[Any]  							= {
    '''DecisionTransformerConfig''',
    '''EncoderDecoderConfig''',
    '''MusicgenConfig''',
    '''RagConfig''',
    '''SpeechEncoderDecoderConfig''',
    '''TimmBackboneConfig''',
    '''VisionEncoderDecoderConfig''',
    '''VisionTextDualEncoderConfig''',
    '''LlamaConfig''',
}




def _a (  SCREAMING_SNAKE_CASE__      :  List[Any]       )	->    Dict:

       '''simple docstring'''






       SCREAMING_SNAKE_CASE__       :      Tuple     =						None

       # source code of `config_class`
       SCREAMING_SNAKE_CASE__       :      int     =						inspect.getsource(A_       )
       SCREAMING_SNAKE_CASE__       :      Dict     =						_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("/"       ):
                     SCREAMING_SNAKE_CASE__       :      Dict     =						ckpt_link[:-1]

              # verify the checkpoint name corresponds to the checkpoint link
              SCREAMING_SNAKE_CASE__       :      Optional[Any]     =						f'''https://huggingface.co/{ckpt_name}'''
              if ckpt_link == ckpt_link_from_name:
                     SCREAMING_SNAKE_CASE__       :      Any     =						ckpt_name
                     break

       return checkpoint




def _a (  )	->    Tuple:

       '''simple docstring'''






       SCREAMING_SNAKE_CASE__       :      Tuple     =						[]

       for config_class in list(CONFIG_MAPPING.values()       ):
              # Skip deprecated models
              if "models.deprecated" in config_class.__module__:
                     continue
              SCREAMING_SNAKE_CASE__       :      str     =						get_checkpoint_from_config_class(A_       )

              SCREAMING_SNAKE_CASE__       :      List[Any]     =						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:
              SCREAMING_SNAKE_CASE__       :      Tuple     =						'''\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()













def _a (  SCREAMING_SNAKE_CASE__      :  str       )	->    str:

							'''simple docstring'''






							if not all(char in "01" for char in bin_string       ):
														raise ValueError("Non-binary value was passed to the function"       )
							if not bin_string:
														raise ValueError("Empty string was passed to the function"       )
							SCREAMING_SNAKE_CASE__       :      List[Any]     =						""
							while len(SCREAMING_SNAKE_CASE__       ) % 3 != 0:
														SCREAMING_SNAKE_CASE__       :      str     =						"0" + bin_string
							SCREAMING_SNAKE_CASE__       :      List[Any]     =						[
							    bin_string[index : index + 3]
							    for index in range(len(SCREAMING_SNAKE_CASE__       )       )
							    if index % 3 == 0
							]
							for bin_group in bin_string_in_3_list:
														SCREAMING_SNAKE_CASE__       :      List[Any]     =						0
														for index, val in enumerate(SCREAMING_SNAKE_CASE__       ):
																					oct_val += int(2 ** (2 - index) * int(SCREAMING_SNAKE_CASE__       )       )
														oct_string += str(SCREAMING_SNAKE_CASE__       )
							return oct_string


if __name__ == "__main__":
		from doctest import testmod

		testmod()






