




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


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

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


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

def       _UpperCamelCase					( SCREAMING_SNAKE_CASE__	:					Union[str, Any]				):
 '''simple docstring'''





 UpperCAmelCase__								=			None

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

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

 return checkpoint

def       _UpperCamelCase					( ):
 '''simple docstring'''





 UpperCAmelCase__								=			[]

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

  UpperCAmelCase__								=			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:
  UpperCAmelCase__								=			'\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()







from __future__ import annotations







def  _SCREAMING_SNAKE_CASE				(   a					,						a					,						a  )      ->      float:
					if days_between_payments <= 0:
										raise ValueError('days_between_payments must be > 0'  )
					if daily_interest_rate < 0:
										raise ValueError('daily_interest_rate must be >= 0'  )
					if principal <= 0:
										raise ValueError('principal must be > 0'  )
					return principal * daily_interest_rate * days_between_payments







def  _SCREAMING_SNAKE_CASE				(   a					,						a					,						a					,						)      ->      float:
					if number_of_compounding_periods <= 0:
										raise ValueError('number_of_compounding_periods must be > 0'  )
					if nominal_annual_interest_rate_percentage < 0:
										raise ValueError('nominal_annual_interest_rate_percentage must be >= 0'  )
					if principal <= 0:
										raise ValueError('principal must be > 0'  )

					return principal * (
					    (1 + nominal_annual_interest_rate_percentage) ** number_of_compounding_periods
					    - 1
					)







def  _SCREAMING_SNAKE_CASE				(   a					,						a					,						a					,						)      ->      float:
					if number_of_years <= 0:
										raise ValueError('number_of_years must be > 0'  )
					if nominal_annual_percentage_rate < 0:
										raise ValueError('nominal_annual_percentage_rate must be >= 0'  )
					if principal <= 0:
										raise ValueError('principal must be > 0'  )

					return compound_interest(
					    a					,						nominal_annual_percentage_rate / 3_65					,						number_of_years * 3_65  )


if __name__ == "__main__":
				import doctest

				doctest.testmod()




