


from typing import List, Optional, Union

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


a__    :							List[str]            =					logging.get_logger(__name__)

a__    :							Optional[int]            =					{
    """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"""





	snake_case__    :  Tuple    =      """time_series_transformer"""
	snake_case__    :  Optional[Any]    =      {
	    """hidden_size""": """d_model""",
	    """num_attention_heads""": """encoder_attention_heads""",
	    """num_hidden_layers""": """encoder_layers""",
	}




	def __init__(			self      :    Any      ,      UpperCAmelCase__      :    Dict = None      ,      UpperCAmelCase__      :    Optional[int] = None      ,      UpperCAmelCase__      :    List[Any] = "student_t"      ,      UpperCAmelCase__      :    List[Any] = "nll"      ,      UpperCAmelCase__      :    Tuple = 1      ,      UpperCAmelCase__      :    str = [1, 2, 3, 4, 5, 6, 7]      ,      UpperCAmelCase__      :    Optional[int] = "mean"      ,      UpperCAmelCase__      :    Any = 0      ,      UpperCAmelCase__      :    Optional[Any] = 0      ,      UpperCAmelCase__      :    Any = 0      ,      UpperCAmelCase__      :    Any = 0      ,      UpperCAmelCase__      :    Union[str, Any] = None      ,      UpperCAmelCase__      :    Tuple = None      ,      UpperCAmelCase__      :    Optional[Any] = 3_2      ,      UpperCAmelCase__      :    Dict = 3_2      ,      UpperCAmelCase__      :    Any = 2      ,      UpperCAmelCase__      :    Dict = 2      ,      UpperCAmelCase__      :    Optional[Any] = 2      ,      UpperCAmelCase__      :    int = 2      ,      UpperCAmelCase__      :    int = True      ,      UpperCAmelCase__      :    Dict = "gelu"      ,      UpperCAmelCase__      :    List[str] = 6_4      ,      UpperCAmelCase__      :    Optional[int] = 0.1      ,      UpperCAmelCase__      :    int = 0.1      ,      UpperCAmelCase__      :    List[Any] = 0.1      ,      UpperCAmelCase__      :    Optional[int] = 0.1      ,      UpperCAmelCase__      :    Tuple = 0.1      ,      UpperCAmelCase__      :    int = 1_0_0      ,      UpperCAmelCase__      :    List[Any] = 0.02      ,      UpperCAmelCase__      :    str=True      ,      **UpperCAmelCase__      :    Dict      ,      )	->     Optional[Any]:
						# time series specific configuration
						__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(_lowercase       ) != 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(_lowercase       ) != 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(5_0      ,      (cat + 1) // 2       ) for cat in self.cardinality]
						__SCREAMING_SNAKE_CASE						       =    num_parallel_samples

						# Transformer architecture configuration
						__SCREAMING_SNAKE_CASE						       =    input_size * len(_lowercase       ) + 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=_lowercase      ,      **_lowercase       )




	@property
	def   UpperCAmelCase_				(			self      :    Union[str, Any]       )	->     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"""







from __future__ import annotations




def        UpperCAmelCase__	(lowerCAmelCase_       ):




					'''simple docstring'''


					if not nums:
										return 0
					__SCREAMING_SNAKE_CASE						       =    nums[0]
					__SCREAMING_SNAKE_CASE						       =    0
					for num in nums[1:]:
										__SCREAMING_SNAKE_CASE       ,  __SCREAMING_SNAKE_CASE						       =    (
										    max_excluding + num,
										    max(lowerCAmelCase_  ,						lowerCAmelCase_       ),
										)
					return max(lowerCAmelCase_  ,						lowerCAmelCase_       )


if __name__ == "__main__":
		import doctest

		doctest.testmod()
