

from typing import List, Optional

from ...configuration_utils import PretrainedConfig
from ...utils import logging


_lowerCAmelCase  :      str			 =logging.get_logger(__name__)

_lowerCAmelCase  :      Any			 ={
    """huggingface/autoformer-tourism-monthly""": """https://huggingface.co/huggingface/autoformer-tourism-monthly/resolve/main/config.json""",
}

class __UpperCamelCase     (				_a		):






					'''simple docstring'''



					__magic_name__        =   "autoformer"
					__magic_name__        =   {
					    "hidden_size": "d_model",
					    "num_attention_heads": "encoder_attention_heads",
					    "num_hidden_layers": "encoder_layers",
					}





					def __init__(				self				,      lowerCamelCase__ = None				,      lowerCamelCase__ = None				,      lowerCamelCase__ = "student_t"				,      lowerCamelCase__ = "nll"				,      lowerCamelCase__ = 1				,      lowerCamelCase__ = [1, 2, 3, 4, 5, 6, 7]				,      lowerCamelCase__ = True				,      lowerCamelCase__ = 0				,      lowerCamelCase__ = 0				,      lowerCamelCase__ = 0				,      lowerCamelCase__ = 0				,      lowerCamelCase__ = None				,      lowerCamelCase__ = None				,      lowerCamelCase__ = 6_4				,      lowerCamelCase__ = 2				,      lowerCamelCase__ = 2				,      lowerCamelCase__ = 2				,      lowerCamelCase__ = 2				,      lowerCamelCase__ = 3_2				,      lowerCamelCase__ = 3_2				,      lowerCamelCase__ = "gelu"				,      lowerCamelCase__ = 0.1				,      lowerCamelCase__ = 0.1				,      lowerCamelCase__ = 0.1				,      lowerCamelCase__ = 0.1				,      lowerCamelCase__ = 0.1				,      lowerCamelCase__ = 1_0_0				,      lowerCamelCase__ = 0.02				,      lowerCamelCase__ = True				,      lowerCamelCase__=True				,      lowerCamelCase__ = 1_0				,      lowerCamelCase__ = 2_5				,      lowerCamelCase__ = 3				,      **lowerCamelCase__				,      ):
						# time series specific configuration
						UpperCAmelCase__:	Optional[Any]									= prediction_length
						UpperCAmelCase__:	Optional[int]									= context_length if context_length is not None else prediction_length
						UpperCAmelCase__:	List[str]									= distribution_output
						UpperCAmelCase__:	List[str]									= loss
						UpperCAmelCase__:	List[Any]									= input_size
						UpperCAmelCase__:	Optional[int]									= num_time_features
						UpperCAmelCase__:	Tuple									= lags_sequence
						UpperCAmelCase__:	Any									= scaling
						UpperCAmelCase__:	Optional[Any]									= num_dynamic_real_features
						UpperCAmelCase__:	Dict									= num_static_real_features
						UpperCAmelCase__:	Any									= num_static_categorical_features
						if cardinality is not None and num_static_categorical_features > 0:
							if len(lowerCamelCase__						) != num_static_categorical_features:
								raise ValueError(
								    "The cardinality should be a list of the same length as `num_static_categorical_features`"						)
							UpperCAmelCase__:	Optional[int]									= cardinality
						else:
							UpperCAmelCase__:	Dict									= [0]
						if embedding_dimension is not None and num_static_categorical_features > 0:
							if len(lowerCamelCase__						) != num_static_categorical_features:
								raise ValueError(
								    "The embedding dimension should be a list of the same length as `num_static_categorical_features`"						)
							UpperCAmelCase__:	Tuple									= embedding_dimension
						else:
							UpperCAmelCase__:	Union[str, Any]									= [min(5_0				,      (cat + 1) // 2						) for cat in self.cardinality]
						UpperCAmelCase__:	Any									= num_parallel_samples

						# Transformer architecture configuration
						UpperCAmelCase__:	Any									= input_size * len(self.lags_sequence						) + self._number_of_features
						UpperCAmelCase__:	Optional[int]									= d_model
						UpperCAmelCase__:	List[str]									= encoder_attention_heads
						UpperCAmelCase__:	Tuple									= decoder_attention_heads
						UpperCAmelCase__:	Any									= encoder_ffn_dim
						UpperCAmelCase__:	Tuple									= decoder_ffn_dim
						UpperCAmelCase__:	List[str]									= encoder_layers
						UpperCAmelCase__:	Tuple									= decoder_layers

						UpperCAmelCase__:	List[Any]									= dropout
						UpperCAmelCase__:	str									= attention_dropout
						UpperCAmelCase__:	Optional[int]									= activation_dropout
						UpperCAmelCase__:	Optional[Any]									= encoder_layerdrop
						UpperCAmelCase__:	Tuple									= decoder_layerdrop

						UpperCAmelCase__:	Dict									= activation_function
						UpperCAmelCase__:	Optional[int]									= init_std

						UpperCAmelCase__:	Optional[Any]									= use_cache

						# Autoformer
						UpperCAmelCase__:	Optional[int]									= label_length
						UpperCAmelCase__:	Optional[int]									= moving_average
						UpperCAmelCase__:	Dict									= autocorrelation_factor

						super().__init__(is_encoder_decoder=lowerCamelCase__				,      **lowerCamelCase__						)





					@property
					def    _UpperCAmelCase    (				self						):
						return (
						    sum(self.embedding_dimension						)
						    + self.num_dynamic_real_features
						    + self.num_time_features
						    + self.num_static_real_features
						    + self.input_size * 2  # the log1p(abs(loc)) and log(scale) features
						)


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  :      Dict			 =direct_transformers_import(PATH_TO_TRANSFORMERS)

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


_lowerCAmelCase  :      Union[str, Any]			 ={
    """DecisionTransformerConfig""",
    """EncoderDecoderConfig""",
    """MusicgenConfig""",
    """RagConfig""",
    """SpeechEncoderDecoderConfig""",
    """TimmBackboneConfig""",
    """VisionEncoderDecoderConfig""",
    """VisionTextDualEncoderConfig""",
    """LlamaConfig""",
}



def 			_A	(      SCREAMING_SNAKE_CASE      ):
	UpperCAmelCase__:	str									= None

	# source code of `config_class`
	UpperCAmelCase__:	Optional[int]									= inspect.getsource(SCREAMING_SNAKE_CASE      )
	UpperCAmelCase__:	List[Any]									= _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__:	Any									= ckpt_link[:-1]

		# verify the checkpoint name corresponds to the checkpoint link
		UpperCAmelCase__:	int									= f"https://huggingface.co/{ckpt_name}"
		if ckpt_link == ckpt_link_from_name:
			UpperCAmelCase__:	Optional[int]									= ckpt_name
			break

	return checkpoint



def 			_A	(      ):
	UpperCAmelCase__:	List[str]									= []

	for config_class in list(CONFIG_MAPPING.values()      ):
		# Skip deprecated models
		if "models.deprecated" in config_class.__module__:
			continue
		UpperCAmelCase__:	Optional[Any]									= get_checkpoint_from_config_class(SCREAMING_SNAKE_CASE      )

		UpperCAmelCase__:	List[str]									= 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__:	Dict									= "\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()