



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
__lowerCamelCase  :				Optional[Any]					=					"src/transformers"


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

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


__lowerCamelCase  :				Dict					=					{
    "CLIPConfigMixin",
    "DecisionTransformerConfigMixin",
    "EncoderDecoderConfigMixin",
    "RagConfigMixin",
    "SpeechEncoderDecoderConfigMixin",
    "VisionEncoderDecoderConfigMixin",
    "VisionTextDualEncoderConfigMixin",
}

def  lowerCamelCase_()			->							List[Any]:
						UpperCAmelCase								=  []

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

												# source code of `config_class`
												UpperCAmelCase								=  inspect.getsource(lowerCamelCase_     )
												UpperCAmelCase								=  _re_checkpoint.findall(lowerCamelCase_     )

												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')`
																		UpperCAmelCase								=  checkpoint

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

												UpperCAmelCase								=  config_class.__name__
												if not checkpoint_found and name not in CONFIG_CLASSES_TO_IGNORE_FOR_DOCSTRING_CHECKPOINT_CHECK:
																		configs_without_checkpoint.append(lowerCamelCase_     )

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


if __name__ == "__main__":
		check_config_docstrings_have_checkpoints()







from __future__ import annotations

from math import pi

# Define the Reduced Planck Constant ℏ (H bar), speed of light C, value of
# Pi and the function
SCREAMING_SNAKE_CASE			: Union[str, Any]				   =					1.0_5457_1817E-34  # unit of ℏ : J * s

SCREAMING_SNAKE_CASE			: int				   =					3E8  # unit of c : m * s^-1



def 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_					)       ->		dict[str, float]:

    if (force, area, distance).count(0					) != 1:
        raise ValueError('One and only one argument must be 0'					)
    if force < 0:
        raise ValueError('Magnitude of force can not be negative'					)
    if distance < 0:
        raise ValueError('Distance can not be negative'					)
    if area < 0:
        raise ValueError('Area can not be negative'					)
    if force == 0:
        _lowercase			:				int 						=						(REDUCED_PLANCK_CONSTANT * SPEED_OF_LIGHT * pi**2 * area) / (
            240 * (distance) ** 4
        )
        return {"force": force}
    elif area == 0:
        _lowercase			:				List[Any] 						=						(240 * force * (distance) ** 4) / (
            REDUCED_PLANCK_CONSTANT * SPEED_OF_LIGHT * pi**2
        )
        return {"area": area}
    elif distance == 0:
        _lowercase			:				List[Any] 						=						(
            (REDUCED_PLANCK_CONSTANT * SPEED_OF_LIGHT * pi**2 * area) / (240 * force)
        ) ** (1 / 4)
        return {"distance": distance}
    raise ValueError('One and only one argument must be 0'					)


# Run doctest
if __name__ == "__main__":
 import doctest

 doctest.testmod()


