





'''simple docstring'''

from typing import List, Optional, Union

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


a        =						logging.get_logger(__name__)

a        =						{
    "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 __a (   _snake_case			):
   __UpperCamelCase   : List[Any]	      =	'time_series_transformer'
   __UpperCamelCase   : Dict	      =	{
       'hidden_size': 'd_model',
       'num_attention_heads': 'encoder_attention_heads',
       'num_hidden_layers': 'encoder_layers',
   }





   def __init__(					self				:			List[str]				,lowerCamelCase				:			Optional[int] = None				,lowerCamelCase				:			Optional[int] = None				,lowerCamelCase				:			str = "student_t"				,lowerCamelCase				:			str = "nll"				,lowerCamelCase				:			int = 1				,lowerCamelCase				:			List[int] = [1, 2, 3, 4, 5, 6, 7]				,lowerCamelCase				:			Optional[Union[str, bool]] = "mean"				,lowerCamelCase				:			int = 0				,lowerCamelCase				:			int = 0				,lowerCamelCase				:			int = 0				,lowerCamelCase				:			int = 0				,lowerCamelCase				:			Optional[List[int]] = None				,lowerCamelCase				:			Optional[List[int]] = None				,lowerCamelCase				:			int = 32				,lowerCamelCase				:			int = 32				,lowerCamelCase				:			int = 2				,lowerCamelCase				:			int = 2				,lowerCamelCase				:			int = 2				,lowerCamelCase				:			int = 2				,lowerCamelCase				:			bool = True				,lowerCamelCase				:			str = "gelu"				,lowerCamelCase				:			int = 64				,lowerCamelCase				:			float = 0.1				,lowerCamelCase				:			float = 0.1				,lowerCamelCase				:			float = 0.1				,lowerCamelCase				:			float = 0.1				,lowerCamelCase				:			float = 0.1				,lowerCamelCase				:			int = 100				,lowerCamelCase				:			float = 0.02				,lowerCamelCase				:			Optional[Any]=True				,**lowerCamelCase				:			Dict				,):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE      							=       prediction_length
      __SCREAMING_SNAKE_CASE      							=       context_length or prediction_length
      __SCREAMING_SNAKE_CASE      							=       distribution_output
      __SCREAMING_SNAKE_CASE      							=       loss
      __SCREAMING_SNAKE_CASE      							=       input_size
      __SCREAMING_SNAKE_CASE      							=       num_time_features
      __SCREAMING_SNAKE_CASE      							=       lags_sequence
      __SCREAMING_SNAKE_CASE      							=       scaling
      __SCREAMING_SNAKE_CASE      							=       num_dynamic_real_features
      __SCREAMING_SNAKE_CASE      							=       num_static_real_features
      __SCREAMING_SNAKE_CASE      							=       num_static_categorical_features
      if cardinality 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`"""    )
         __SCREAMING_SNAKE_CASE      							=       cardinality
      else:
         __SCREAMING_SNAKE_CASE      							=       [0]
      if embedding_dimension 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`"""    )
         __SCREAMING_SNAKE_CASE      							=       embedding_dimension
      else:
         __SCREAMING_SNAKE_CASE      							=       [min(50				,(cat + 1) // 2    ) for cat in self.cardinality]
      __SCREAMING_SNAKE_CASE      							=       num_parallel_samples

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

      __SCREAMING_SNAKE_CASE      							=       dropout
      __SCREAMING_SNAKE_CASE      							=       attention_dropout
      __SCREAMING_SNAKE_CASE      							=       activation_dropout
      __SCREAMING_SNAKE_CASE      							=       encoder_layerdrop
      __SCREAMING_SNAKE_CASE      							=       decoder_layerdrop

      __SCREAMING_SNAKE_CASE      							=       activation_function
      __SCREAMING_SNAKE_CASE      							=       init_std

      __SCREAMING_SNAKE_CASE      							=       use_cache

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





   @property
   def      UpperCAmelCase__     (					self				:			List[Any]    ):

      '''simple docstring'''

      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 						__magic_name__       (							__UpperCAmelCase      )						->					bool:

   '''simple docstring'''







   if num < 0:
      return False

   __SCREAMING_SNAKE_CASE      							=       num
   __SCREAMING_SNAKE_CASE      							=       0
   while num > 0:
      __SCREAMING_SNAKE_CASE      							=       rev_num * 10 + (num % 10)
      num //= 10

   return num_copy == rev_num


if __name__ == "__main__":
    import doctest

    doctest.testmod()





