





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
UpperCAmelCase     :     Dict							=	"""src/transformers"""


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

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


UpperCAmelCase     :     str							=	{
    """DecisionTransformerConfig""",
    """EncoderDecoderConfig""",
    """MusicgenConfig""",
    """RagConfig""",
    """SpeechEncoderDecoderConfig""",
    """TimmBackboneConfig""",
    """VisionEncoderDecoderConfig""",
    """VisionTextDualEncoderConfig""",
    """LlamaConfig""",
}
def 					_A	(		SCREAMING_SNAKE_CASE					:       Optional[Any]						):





  """simple docstring"""



  a__     : List[str]  =None

  # source code of `config_class`
  a__     : Optional[Any]  =inspect.getsource(A__						)
  a__     : 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("/"						):
      a__     : List[str]  =ckpt_link[:-1]

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

  return checkpoint
def 					_A	(		):





  """simple docstring"""



  a__     : Union[str, Any]  =[]

  for config_class in list(CONFIG_MAPPING.values()						):
    # Skip deprecated models
    if "models.deprecated" in config_class.__module__:
      continue
    a__     : List[str]  =get_checkpoint_from_config_class(A__						)

    a__     : Dict  =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:
    a__     : 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()













import copy
from dataclasses import dataclass, field
from typing import ClassVar, Dict

from ..features import ClassLabel, Features, Image
from .base import TaskTemplate







@dataclass(frozen=UpperCamelCase__)
class     __lowerCAmelCase	(   UpperCamelCase__):
      _lowercase    : str            =      field(default="""image-classification"""						,    metadata={"""include_in_asdict_even_if_is_default""": True})
      _lowercase    : ClassVar[Features]            =      Features({"""image""": Image()})
      _lowercase    : ClassVar[Features]            =      Features({"""labels""": ClassLabel})
      _lowercase    : str            =      "image"
      _lowercase    : str            =      "labels"







      def        _lowercase  (   self		,				lowerCAmelCase__							)       ->						List[Any]:



        '''simple docstring'''




        if self.label_column not in features:
          raise ValueError(F'''Column {self.label_column} is not present in features.'''							)
        if not isinstance(features[self.label_column]		,				lowerCAmelCase__							):
          raise ValueError(F'''Column {self.label_column} is not a ClassLabel.'''							)
        a__     : int  =copy.deepcopy(self							)
        a__     : Dict  =self.label_schema.copy()
        a__     : int  =features[self.label_column]
        a__     : str  =label_schema
        return task_template







      @property
      def        _lowercase  (   self							)       ->						Dict[str, str]:



        '''simple docstring'''




        return {
            self.image_column: "image",
            self.label_column: "labels",
        }






