


"""simple docstring"""
from typing import List, Optional, Union

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


SCREAMING_SNAKE_CASE :    Optional[int]									=				logging.get_logger(__name__)

SCREAMING_SNAKE_CASE :    List[str]									=				{
    """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 (							__snake_case				):






		'''simple docstring'''

		lowerCamelCase__				='time_series_transformer'
		lowerCamelCase__				={
		    '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_ = "mean"				,       a_ = 0				,       a_ = 0				,       a_ = 0				,       a_ = 0				,       a_ = None				,       a_ = None				,       a_ = 32				,       a_ = 32				,       a_ = 2				,       a_ = 2				,       a_ = 2				,       a_ = 2				,       a_ = True				,       a_ = "gelu"				,       a_ = 64				,       a_ = 0.1				,       a_ = 0.1				,       a_ = 0.1				,       a_ = 0.1				,       a_ = 0.1				,       a_ = 1_00				,       a_ = 0.02				,       a_=True				,       **a_				,       ):





			'''simple docstring'''

			__snake_case	:						Union[str, Any]						=				prediction_length
			__snake_case	:						List[str]						=				context_length or prediction_length
			__snake_case	:						Tuple						=				distribution_output
			__snake_case	:						Union[str, Any]						=				loss
			__snake_case	:						Tuple						=				input_size
			__snake_case	:						Optional[Any]						=				num_time_features
			__snake_case	:						Tuple						=				lags_sequence
			__snake_case	:						Optional[int]						=				scaling
			__snake_case	:						Optional[Any]						=				num_dynamic_real_features
			__snake_case	:						Optional[Any]						=				num_static_real_features
			__snake_case	:						List[str]						=				num_static_categorical_features
			if cardinality 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`'''					)
				__snake_case	:						Dict						=				cardinality
			else:
				__snake_case	:						Optional[int]						=				[0]
			if embedding_dimension 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`'''					)
				__snake_case	:						Dict						=				embedding_dimension
			else:
				__snake_case	:						int						=				[min(50				,       (cat + 1) // 2					) for cat in self.cardinality]
			__snake_case	:						int						=				num_parallel_samples

			# Transformer architecture configuration
			__snake_case	:						Union[str, Any]						=				input_size * len(a_					) + self._number_of_features
			__snake_case	:						Any						=				d_model
			__snake_case	:						Union[str, Any]						=				encoder_attention_heads
			__snake_case	:						Any						=				decoder_attention_heads
			__snake_case	:						Any						=				encoder_ffn_dim
			__snake_case	:						List[Any]						=				decoder_ffn_dim
			__snake_case	:						Tuple						=				encoder_layers
			__snake_case	:						Union[str, Any]						=				decoder_layers

			__snake_case	:						int						=				dropout
			__snake_case	:						List[str]						=				attention_dropout
			__snake_case	:						Optional[int]						=				activation_dropout
			__snake_case	:						Dict						=				encoder_layerdrop
			__snake_case	:						Optional[Any]						=				decoder_layerdrop

			__snake_case	:						int						=				activation_function
			__snake_case	:						Union[str, Any]						=				init_std

			__snake_case	:						int						=				use_cache

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



		@property
		def 				SCREAMING_SNAKE_CASE  (self					):





			'''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"""
import numpy as np






def 		lowercase							(     _snake_case						:      int     ,   _snake_case						:      Optional[Any]     ,   _snake_case						:      Optional[int]     ,   _snake_case						:      int     ,   _snake_case						:      Union[str, Any]     )     ->Dict:
	"""simple docstring"""





	__snake_case	:						Union[str, Any]						=				int(np.ceil((x_end - xa) / h     )     )
	__snake_case	:						Dict						=				np.zeros((n + 1,)     )
	__snake_case	:						List[Any]						=				ya
	__snake_case	:						int						=				xa

	for k in range(_snake_case     ):
		__snake_case	:						Any						=				f(_snake_case     ,   y[k]     )
		__snake_case	:						List[Any]						=				f(x + 0.5 * h     ,   y[k] + 0.5 * h * ka     )
		__snake_case	:						int						=				f(x + 0.5 * h     ,   y[k] + 0.5 * h * ka     )
		__snake_case	:						Optional[int]						=				f(x + h     ,   y[k] + h * ka     )
		__snake_case	:						Optional[int]						=				y[k] + (1 / 6) * h * (ka + 2 * ka + 2 * ka + ka)
		x += h

	return y


if __name__ == "__main__":
			import doctest

			doctest.testmod()





