


'''simple docstring'''



from typing import List, Optional, Union

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


A__						:   Optional[Any]				=    logging.get_logger(__name__)

A__						:   Dict				=    {
    """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_    (_UpperCAmelCase    ):





    """simple docstring"""






    lowerCamelCase    :   List[Any]					=     'time_series_transformer'
    lowerCamelCase    :   Union[str, Any]					=     {
        'hidden_size': 'd_model',
        'num_attention_heads': 'encoder_attention_heads',
        'num_hidden_layers': 'encoder_layers',
    }







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

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

         __lowerCamelCase  :      Any														=						dropout
         __lowerCamelCase  :      str														=						attention_dropout
         __lowerCamelCase  :      Tuple														=						activation_dropout
         __lowerCamelCase  :      Tuple														=						encoder_layerdrop
         __lowerCamelCase  :      Optional[Any]														=						decoder_layerdrop

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

         __lowerCamelCase  :      Any														=						use_cache

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







    @property
    def  lowercase_							(				self      )							->	int:
         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'''



# Lint as: python3
import dataclasses
import re
from dataclasses import dataclass
from functools import total_ordering
from typing import Optional, Union


A__						:   Any				=    re.compile(R"""^(?P<major>\d+)""" R"""\.(?P<minor>\d+)""" R"""\.(?P<patch>\d+)$""")





@total_ordering
@dataclass
class   UpperCAmelCase_    :





    """simple docstring"""






    lowerCamelCase    :   str
    lowerCamelCase    :   Optional[str]					=     None
    lowerCamelCase    :   Optional[Union[str, int]]					=     None
    lowerCamelCase    :   Optional[Union[str, int]]					=     None
    lowerCamelCase    :   Optional[Union[str, int]]					=     None







    def  lowercase_							(				self      )							->	List[str]:
         __lowerCamelCase							,			__lowerCamelCase							,			__lowerCamelCase  :      List[Any]														=						_str_to_version_tuple(self.version_str      )







    def __repr__(				self      )							->	Any:
         return f'{self.tuple[0]}.{self.tuple[1]}.{self.tuple[2]}'







    @property
    def  lowercase_							(				self      )							->	int:
         return self.major, self.minor, self.patch







    def  lowercase_							(				self     ,	SCREAMING_SNAKE_CASE_      )							->	List[Any]:
         if isinstance(SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_      ):
              return Version(SCREAMING_SNAKE_CASE_      )
         elif isinstance(SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_      ):
              return other
         raise TypeError(f'{other} (type {type(SCREAMING_SNAKE_CASE_      )}) cannot be compared to version.'      )







    def __eq__(				self     ,	SCREAMING_SNAKE_CASE_      )							->	Optional[Any]:
         try:
              __lowerCamelCase  :      Union[str, Any]														=						self._validate_operand(SCREAMING_SNAKE_CASE_      )
         except (TypeError, ValueError):
              return False
         else:
              return self.tuple == other.tuple







    def __lt__(				self     ,	SCREAMING_SNAKE_CASE_      )							->	List[Any]:
         __lowerCamelCase  :      List[Any]														=						self._validate_operand(SCREAMING_SNAKE_CASE_      )
         return self.tuple < other.tuple







    def __hash__(				self      )							->	List[str]:
         return hash(_version_tuple_to_str(self.tuple      )      )







    @classmethod
    def  lowercase_							(				cls     ,	SCREAMING_SNAKE_CASE_      )							->	List[str]:
         __lowerCamelCase  :      str														=						{f.name for f in dataclasses.fields(cls      )}
         return cls(**{k: v for k, v in dic.items() if k in field_names}      )







    def  lowercase_							(				self      )							->	str:
         return self.version_str







def      UpperCAmelCase__   (      UpperCAmelCase_       :							Union[str, Any]				)	->						str:
     __lowerCamelCase  :      str														=						_VERSION_REG.match(UpperCAmelCase_				)
     if not res:
          raise ValueError(F'Invalid version \'{version_str}\'. Format should be x.y.z with {{x,y,z}} being digits.'				)
     return tuple(int(UpperCAmelCase_				) for v in [res.group('major'				), res.group('minor'				), res.group('patch'				)]				)



def      UpperCAmelCase__   (      UpperCAmelCase_       :							List[str]				)	->						Dict:
     return ".".join(str(UpperCAmelCase_				) for v in version_tuple				)






