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_     =	'''src/transformers'''


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

lowerCAmelCase_     =	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_     =	re.compile(R'''\[(.+?)\]\((https://huggingface\.co/.+?)\)''')


lowerCAmelCase_     =	{
    '''DecisionTransformerConfig''',
    '''EncoderDecoderConfig''',
    '''MusicgenConfig''',
    '''RagConfig''',
    '''SpeechEncoderDecoderConfig''',
    '''TimmBackboneConfig''',
    '''VisionEncoderDecoderConfig''',
    '''VisionTextDualEncoderConfig''',
    '''LlamaConfig''',
}



def      lowerCamelCase_(__SCREAMING_SNAKE_CASE  )->    Union[str, Any]:
							_SCREAMING_SNAKE_CASE		:						Dict			  =    None

							# source code of `config_class`
							_SCREAMING_SNAKE_CASE		:						str			  =    inspect.getsource(__SCREAMING_SNAKE_CASE  )
							_SCREAMING_SNAKE_CASE		:						int			  =    _re_checkpoint.findall(__SCREAMING_SNAKE_CASE  )

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

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

							return checkpoint



def      lowerCamelCase_()->    List[str]:
							_SCREAMING_SNAKE_CASE		:						str			  =    []

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

														_SCREAMING_SNAKE_CASE		:						List[Any]			  =    config_class.__name__
														if checkpoint is None and name not in CONFIG_CLASSES_TO_IGNORE_FOR_DOCSTRING_CHECKPOINT_CHECK:
																					configs_without_checkpoint.append(__SCREAMING_SNAKE_CASE  )

							if len(__SCREAMING_SNAKE_CASE  ) > 0:
														_SCREAMING_SNAKE_CASE		:						List[Any]			  =    """\n""".join(sorted(__SCREAMING_SNAKE_CASE  )  )
														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 decimal import Decimal, getcontext
from math import ceil, factorial



def      lowerCamelCase_(__SCREAMING_SNAKE_CASE  )->    str:

							if not isinstance(__SCREAMING_SNAKE_CASE     ,	__SCREAMING_SNAKE_CASE  ):
														raise TypeError("""Undefined for non-integers"""  )
							elif precision < 1:
														raise ValueError("""Undefined for non-natural numbers"""  )

							_SCREAMING_SNAKE_CASE		:						int			  =    precision
							_SCREAMING_SNAKE_CASE		:						Dict			  =    ceil(precision / 14  )
							_SCREAMING_SNAKE_CASE		:						int			  =    426_880 * Decimal(10_005  ).sqrt()
							_SCREAMING_SNAKE_CASE		:						Union[str, Any]			  =    1
							_SCREAMING_SNAKE_CASE		:						str			  =    13_591_409
							_SCREAMING_SNAKE_CASE		:						Tuple			  =    Decimal(__SCREAMING_SNAKE_CASE  )
							for k in range(1     ,	__SCREAMING_SNAKE_CASE  ):
														_SCREAMING_SNAKE_CASE		:						Tuple			  =    factorial(6 * k  ) // (factorial(3 * k  ) * factorial(__SCREAMING_SNAKE_CASE  ) ** 3)
														linear_term += 545_140_134
														exponential_term *= -262_537_412_640_768_000
														partial_sum += Decimal(multinomial_term * linear_term  ) / exponential_term
							return str(constant_term / partial_sum  )[:-1]


if __name__ == "__main__":
			lowerCAmelCase_     =	50
			print(F"The first {n} digits of pi is: {pi(n)}")


