


'''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
_UpperCAmelCase				: Union[str, Any]							    =				"""src/transformers"""


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

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


_UpperCAmelCase				: Optional[int]							    =				{
    """DecisionTransformerConfig""",
    """EncoderDecoderConfig""",
    """MusicgenConfig""",
    """RagConfig""",
    """SpeechEncoderDecoderConfig""",
    """TimmBackboneConfig""",
    """VisionEncoderDecoderConfig""",
    """VisionTextDualEncoderConfig""",
    """LlamaConfig""",
}

def 							__magic_name__(						lowerCamelCase):
						__lowerCAmelCase							       =				None

						# source code of `config_class`
						__lowerCAmelCase							       =				inspect.getsource(lowerCamelCase)
						__lowerCAmelCase							       =				_re_checkpoint.findall(lowerCamelCase)

						# 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('''/'''):
																		__lowerCAmelCase							       =				ckpt_link[:-1]

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

						return checkpoint

def 							__magic_name__(						):
						__lowerCAmelCase							       =				[]

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

												__lowerCAmelCase							       =				config_class.__name__
												if checkpoint is None and name not in CONFIG_CLASSES_TO_IGNORE_FOR_DOCSTRING_CHECKPOINT_CHECK:
																		configs_without_checkpoint.append(lowerCamelCase)

						if len(lowerCamelCase) > 0:
												__lowerCAmelCase							       =				'''\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()





'''simple docstring'''

from math import asin, atan, cos, radians, sin, sqrt, tan

_UpperCAmelCase				: str							    =				6_37_81_37.0
_UpperCAmelCase				: Tuple							    =				6_35_67_52.31_42_45
_UpperCAmelCase				: Optional[Any]							    =				6_3_7_8_1_3_7

def 							__magic_name__(						lowerCamelCase,				lowerCamelCase,				lowerCamelCase,				lowerCamelCase):
						__lowerCAmelCase							       =				(AXIS_A - AXIS_B) / AXIS_A
						__lowerCAmelCase							       =				atan((1 - flattening) * tan(radians(lowerCamelCase)))
						__lowerCAmelCase							       =				atan((1 - flattening) * tan(radians(lowerCamelCase)))
						__lowerCAmelCase							       =				radians(lowerCamelCase)
						__lowerCAmelCase							       =				radians(lowerCamelCase)
						# Equation
						__lowerCAmelCase							       =				sin((phi_a - phi_a) / 2)
						__lowerCAmelCase							       =				sin((lambda_a - lambda_a) / 2)
						# Square both values
						sin_sq_phi *= sin_sq_phi
						sin_sq_lambda *= sin_sq_lambda
						__lowerCAmelCase							       =				sqrt(sin_sq_phi + (cos(lowerCamelCase) * cos(lowerCamelCase) * sin_sq_lambda))
						return 2 * RADIUS * asin(lowerCamelCase)


if __name__ == "__main__":
	import doctest

	doctest.testmod()

