




"""simple docstring"""


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


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

_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("""\[(.+?)\]\((https://huggingface\.co/.+?)\)""")


_A													=      {
    """CLIPConfigMixin""",
    """DecisionTransformerConfigMixin""",
    """EncoderDecoderConfigMixin""",
    """RagConfigMixin""",
    """SpeechEncoderDecoderConfigMixin""",
    """VisionEncoderDecoderConfigMixin""",
    """VisionTextDualEncoderConfigMixin""",
}



def 	lowercase_				(			)						->    Union[str, Any]:
      lowerCAmelCase__      :			int   =	[]

      for config_class in list(CONFIG_MAPPING.values()				):
            lowerCAmelCase__      :			Dict   =	False

            # source code of `config_class`
            lowerCAmelCase__      :			Dict   =	inspect.getsource(__UpperCAmelCase				)
            lowerCAmelCase__      :			List[str]   =	_re_checkpoint.findall(__UpperCAmelCase				)

            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')`
                  lowerCAmelCase__ ,   lowerCAmelCase__      :			Tuple   =	checkpoint

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

            lowerCAmelCase__      :			List[str]   =	config_class.__name__
            if not checkpoint_found and name not in CONFIG_CLASSES_TO_IGNORE_FOR_DOCSTRING_CHECKPOINT_CHECK:
                  configs_without_checkpoint.append(__UpperCAmelCase				)

      if len(__UpperCAmelCase				) > 0:
            lowerCAmelCase__      :			Dict   =	"""\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()











"""simple docstring"""


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

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


@dataclass(frozen=a_						)
class _lowerCamelCase    (					a_						):
   _lowerCamelCase    :str     				=     field(default="audio-classification"       ,	metadata={"include_in_asdict_even_if_is_default": True}						)
   _lowerCamelCase    :ClassVar[Features]     				=     Features({"audio": Audio()}						)
   _lowerCamelCase    :ClassVar[Features]     				=     Features({"labels": ClassLabel}						)
   _lowerCamelCase    :str     				=     "audio"
   _lowerCamelCase    :str     				=     "labels"






   def 	_lowerCAmelCase   (		self       :		str   ,     UpperCamelCase       :		Optional[int]   )			->						Union[str, 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]   ,     UpperCamelCase   ):
               raise ValueError(f"""Column {self.label_column} is not a ClassLabel."""   )
         lowerCAmelCase__      :			str   =	copy.deepcopy(self   )
         lowerCAmelCase__      :			Optional[int]   =	self.label_schema.copy()
         lowerCAmelCase__      :			List[Any]   =	features[self.label_column]
         lowerCAmelCase__      :			Optional[int]   =	label_schema
         return task_template






   @property
   def 	_lowerCAmelCase   (		self       :		List[Any]   )			->						Dict[str, str]:

         """simple docstring"""
         return {
             self.audio_column: "audio",
             self.label_column: "labels",
         }





