



"""simple docstring"""

from typing import List, Optional, Union

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


lowercase__					:						str												=			logging.get_logger(__name__)

lowercase__					:						List[Any]												=			{
    '''huggingface/time-series-transformer-tourism-monthly''': (
        '''https://huggingface.co/huggingface/time-series-transformer-tourism-monthly/resolve/main/config.json'''
    ),
    # See all TimeSeriesTransformer models at https://huggingface.co/models?filter=time_series_transformer
}




class  _UpperCAmelCase (    lowerCAmelCase__):
 _lowerCAmelCase     :    Any	      =	"""time_series_transformer"""
 _lowerCAmelCase     :    int	      =	{
     """hidden_size""": """d_model""",
     """num_attention_heads""": """encoder_attention_heads""",
     """num_hidden_layers""": """encoder_layers""",
 }

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

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

     snake_case_				:  Any       =			dropout
     snake_case_				:  Optional[int]       =			attention_dropout
     snake_case_				:  Optional[Any]       =			activation_dropout
     snake_case_				:  Any       =			encoder_layerdrop
     snake_case_				:  int       =			decoder_layerdrop

     snake_case_				:  int       =			activation_function
     snake_case_				:  List[str]       =			init_std

     snake_case_				:  Optional[int]       =			use_cache

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






 @property
 def 		_snake_case      (  self	: str       ):
     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"""

from statistics import mean, stdev




def __lowercase    (							_a	,    _a = 3					):
    snake_case_				:  Optional[int]       =			min(_a					)
    snake_case_				:  str       =			max(_a					)
    # normalize data
    return [round((x - x_min) / (x_max - x_min)	,    _a					) for x in data]






def __lowercase    (							_a	,    _a = 3					):
    snake_case_				:  Any       =			mean(_a					)
    snake_case_				:  str       =			stdev(_a					)
    # standardize data
    return [round((x - mu) / (sigma)	,    _a					) for x in data]





