






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


lowerCamelCase       :       Any        =				{
    '''DecisionTransformerConfig''',
    '''EncoderDecoderConfig''',
    '''MusicgenConfig''',
    '''RagConfig''',
    '''SpeechEncoderDecoderConfig''',
    '''TimmBackboneConfig''',
    '''VisionEncoderDecoderConfig''',
    '''VisionTextDualEncoderConfig''',
    '''LlamaConfig''',
}
def 					snake_case_						(   lowerCAmelCase_				:  Any					):
							__lowercase					:							Any			=   None

							# source code of `config_class`
							__lowercase					:							List[str]			=   inspect.getsource(lowerCAmelCase_					)
							__lowercase					:							List[str]			=   _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("""/"""					):
																					__lowercase					:							Dict			=   ckpt_link[:-1]

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

							return checkpoint
def 					snake_case_						(   ):
							__lowercase					:							Any			=   []

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

														__lowercase					:							Dict			=   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:
														__lowercase					:							Optional[Any]			=   """\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 maths.prime_check import is_prime
def 					snake_case_						(   lowerCAmelCase_				:  int					):
							if not isinstance(lowerCAmelCase_				,				lowerCAmelCase_					):
														__lowercase					:							Dict			=   F"Input value of [number={number}] must be an integer"
														raise TypeError(lowerCAmelCase_					)
							if is_prime(lowerCAmelCase_					) and is_prime(number + 2					):
														return number + 2
							else:
														return -1


if __name__ == "__main__":
	import doctest

	doctest.testmod()