





'''simple docstring'''




from statistics import mean, stdev







def _lowerCAmelCase     (      _lowerCAmelCase       ,    _lowerCAmelCase = 3    )->     list:
 __UpperCAmelCase					=   min(_lowerCAmelCase    )
 __UpperCAmelCase					=   max(_lowerCAmelCase    )
 # normalize data
 return [round((x - x_min) / (x_max - x_min)       ,    _lowerCAmelCase    ) for x in data]







def _lowerCAmelCase     (      _lowerCAmelCase       ,    _lowerCAmelCase = 3    )->     list:
 __UpperCAmelCase					=   mean(_lowerCAmelCase    )
 __UpperCAmelCase					=   stdev(_lowerCAmelCase    )
 # standardize data
 return [round((x - mu) / (sigma)       ,    _lowerCAmelCase    ) for x in data]












'''simple docstring'''




from typing import List, Optional

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


_A:					str							=				logging.get_logger(__name__)

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






class UpperCAmelCase							(		UpperCAmelCase_							):
    _A :			Tuple						   =       """autoformer"""
    _A :			str						   =       {
        """hidden_size""": """d_model""",
        """num_attention_heads""": """encoder_attention_heads""",
        """num_hidden_layers""": """encoder_layers""",
    }



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

     # Transformer architecture configuration
     __UpperCAmelCase					=   input_size * len(self.lags_sequence					) + self._number_of_features
     __UpperCAmelCase					=   d_model
     __UpperCAmelCase					=   encoder_attention_heads
     __UpperCAmelCase					=   decoder_attention_heads
     __UpperCAmelCase					=   encoder_ffn_dim
     __UpperCAmelCase					=   decoder_ffn_dim
     __UpperCAmelCase					=   encoder_layers
     __UpperCAmelCase					=   decoder_layers

     __UpperCAmelCase					=   dropout
     __UpperCAmelCase					=   attention_dropout
     __UpperCAmelCase					=   activation_dropout
     __UpperCAmelCase					=   encoder_layerdrop
     __UpperCAmelCase					=   decoder_layerdrop

     __UpperCAmelCase					=   activation_function
     __UpperCAmelCase					=   init_std

     __UpperCAmelCase					=   use_cache

     # Autoformer
     __UpperCAmelCase					=   label_length
     __UpperCAmelCase					=   moving_average
     __UpperCAmelCase					=   autocorrelation_factor

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




    @property
    def 					__lowerCamelCase						(  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
     )





