






import unittest

from datasets import load_dataset

from transformers.pipelines import pipeline
from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow







@is_pipeline_test
@require_torch
class    A_	(unittest.TestCase							):
							"""simple docstring"""




							@require_torch
							def 							_A	(		self			:Dict				)				->  str:


										'''simple docstring'''




										snake_case_				:					Any   =       pipeline(
										    task="zero-shot-audio-classification"       ,							model="hf-internal-testing/tiny-clap-htsat-unfused"				)
										snake_case_				:					Optional[int]   =       load_dataset("ashraq/esc50"				)
										snake_case_				:					Optional[int]   =       dataset["train"]["audio"][-1]["array"]
										snake_case_				:					int   =       audio_classifier(lowerCAmelCase__       ,							candidate_labels=["Sound of a dog", "Sound of vaccum cleaner"]				)
										self.assertEqual(
										    nested_simplify(lowerCAmelCase__				)       ,							[{"score": 0.5_0_1, "label": "Sound of a dog"}, {"score": 0.4_9_9, "label": "Sound of vaccum cleaner"}]       ,							)

							@unittest.skip("No models are available in TF"				)
							def 							_A	(		self			:int				)				->  Union[str, Any]:


										'''simple docstring'''




										pass

							@slow
							@require_torch
							def 							_A	(		self			:int				)				->  str:


										'''simple docstring'''




										snake_case_				:					List[str]   =       pipeline(
										    task="zero-shot-audio-classification"       ,							model="laion/clap-htsat-unfused"       ,							)
										# This is an audio of a dog
										snake_case_				:					int   =       load_dataset("ashraq/esc50"				)
										snake_case_				:					str   =       dataset["train"]["audio"][-1]["array"]
										snake_case_				:					List[Any]   =       audio_classifier(lowerCAmelCase__       ,							candidate_labels=["Sound of a dog", "Sound of vaccum cleaner"]				)

										self.assertEqual(
										    nested_simplify(lowerCAmelCase__				)       ,							[
										        {"score": 0.9_9_9, "label": "Sound of a dog"},
										        {"score": 0.0_0_1, "label": "Sound of vaccum cleaner"},
										    ]       ,							)

										snake_case_				:					Optional[Any]   =       audio_classifier([audio] * 5       ,							candidate_labels=["Sound of a dog", "Sound of vaccum cleaner"]				)
										self.assertEqual(
										    nested_simplify(lowerCAmelCase__				)       ,							[
										        [
										            {"score": 0.9_9_9, "label": "Sound of a dog"},
										            {"score": 0.0_0_1, "label": "Sound of vaccum cleaner"},
										        ],
										    ]
										    * 5       ,							)
										snake_case_				:					int   =       audio_classifier(
										    [audio] * 5       ,							candidate_labels=["Sound of a dog", "Sound of vaccum cleaner"]       ,							batch_size=5				)
										self.assertEqual(
										    nested_simplify(lowerCAmelCase__				)       ,							[
										        [
										            {"score": 0.9_9_9, "label": "Sound of a dog"},
										            {"score": 0.0_0_1, "label": "Sound of vaccum cleaner"},
										        ],
										    ]
										    * 5       ,							)






							@unittest.skip("No models are available in TF"				)
							def 							_A	(		self			:Optional[int]				)				->  Union[str, Any]:


										'''simple docstring'''




										pass












'''simple docstring'''




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


__lowerCamelCase   :					Any   							=					{
    '''DecisionTransformerConfig''',
    '''EncoderDecoderConfig''',
    '''MusicgenConfig''',
    '''RagConfig''',
    '''SpeechEncoderDecoderConfig''',
    '''TimmBackboneConfig''',
    '''VisionEncoderDecoderConfig''',
    '''VisionTextDualEncoderConfig''',
    '''LlamaConfig''',
}

def 	__UpperCAmelCase       ( __magic_name__						)->    List[Any]:



			"""simple docstring"""



			snake_case_				:					Tuple   =       None

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

			# 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("/"						):
									snake_case_				:					Optional[Any]   =       ckpt_link[:-1]

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

			return checkpoint

def 	__UpperCAmelCase       ( )->    Dict:



			"""simple docstring"""



			snake_case_				:					Optional[int]   =       []

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

						snake_case_				:					Union[str, Any]   =       config_class.__name__
						if checkpoint is None and name not in CONFIG_CLASSES_TO_IGNORE_FOR_DOCSTRING_CHECKPOINT_CHECK:
									configs_without_checkpoint.append(__magic_name__						)

			if len(__magic_name__						) > 0:
						snake_case_				:					Tuple   =       "\n".join(sorted(__magic_name__						)						)
						raise ValueError(F'''The following configurations don\'t contain any valid checkpoint:\n{message}'''						)


if __name__ == "__main__":
		check_config_docstrings_have_checkpoints()




