


'''simple docstring'''


from typing import List, Optional

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


UpperCAmelCase_		:   Union[str, Any]							   =		logging.get_logger(__name__)

UpperCAmelCase_		:   Optional[Any]							   =		{
    'huggingface/autoformer-tourism-monthly': 'https://huggingface.co/huggingface/autoformer-tourism-monthly/resolve/main/config.json',
}





class     lowercase__  (						_snake_case					):





							'''simple docstring'''


							A_							:      Any      	=  """autoformer"""
							A_							:      Dict      	=  {
							    """hidden_size""": """d_model""",
							    """num_attention_heads""": """encoder_attention_heads""",
							    """num_hidden_layers""": """encoder_layers""",
							}






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

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

											_SCREAMING_SNAKE_CASE :       int     		=      dropout
											_SCREAMING_SNAKE_CASE :       Dict     		=      attention_dropout
											_SCREAMING_SNAKE_CASE :       List[Any]     		=      activation_dropout
											_SCREAMING_SNAKE_CASE :       Tuple     		=      encoder_layerdrop
											_SCREAMING_SNAKE_CASE :       Tuple     		=      decoder_layerdrop

											_SCREAMING_SNAKE_CASE :       int     		=      activation_function
											_SCREAMING_SNAKE_CASE :       str     		=      init_std

											_SCREAMING_SNAKE_CASE :       int     		=      use_cache

											# Autoformer
											_SCREAMING_SNAKE_CASE :       Optional[int]     		=      label_length
											_SCREAMING_SNAKE_CASE :       Dict     		=      moving_average
											_SCREAMING_SNAKE_CASE :       List[Any]     		=      autocorrelation_factor

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






							@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
											)








'''simple docstring'''


def 			snake_case_   (  SCREAMING_SNAKE_CASE__     ):







				"""simple docstring"""





				_SCREAMING_SNAKE_CASE :       int     		=      0
				while len(SCREAMING_SNAKE_CASE__     ) > 1:
								_SCREAMING_SNAKE_CASE :       Any     		=      0
								# Consider two files with minimum cost to be merged
								for _ in range(2     ):
												_SCREAMING_SNAKE_CASE :       Optional[int]     		=      files.index(min(SCREAMING_SNAKE_CASE__     )     )
												temp += files[min_index]
												files.pop(SCREAMING_SNAKE_CASE__     )
								files.append(SCREAMING_SNAKE_CASE__     )
								optimal_merge_cost += temp
				return optimal_merge_cost


if __name__ == "__main__":
				import doctest

				doctest.testmod()




