"""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        _snake_case   (    snake_case_						):
						snake_case__	     =	'''time_series_transformer'''
						snake_case__	     =	{
						    '''hidden_size''': '''d_model''',
						    '''num_attention_heads''': '''encoder_attention_heads''',
						    '''num_hidden_layers''': '''encoder_layers''',
						}






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

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

													__lowerCamelCase    :						List[str]						      =   dropout
													__lowerCamelCase    :						Union[str, Any]						      =   attention_dropout
													__lowerCamelCase    :						Optional[Any]						      =   activation_dropout
													__lowerCamelCase    :						List[Any]						      =   encoder_layerdrop
													__lowerCamelCase    :						Optional[int]						      =   decoder_layerdrop

													__lowerCamelCase    :						int						      =   activation_function
													__lowerCamelCase    :						int						      =   init_std

													__lowerCamelCase    :						str						      =   use_cache

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







						@property
						def 					lowerCamelCase__   (				self					:	Union[str, Any]			):
													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 typing import Dict

from .base import GenericTensor, Pipeline







class _lowerCAmelCase				(      snake_case_	):







   def  lowerCamelCase		(	self						,	UpperCamelCase__=None						,	UpperCamelCase__=None						,	UpperCamelCase__=None						,	**UpperCamelCase__						)	->		Union[str, Any]:

       '''simple docstring'''




       if tokenize_kwargs is None:
           snake_case    :      Optional[Any]      					=    {}

       if truncation is not None:
           if "truncation" in tokenize_kwargs:
               raise ValueError(
                   "truncation parameter defined twice (given as keyword argument as well as in tokenize_kwargs)"						)
           snake_case    :      List[str]      					=    truncation

       snake_case    :      Union[str, Any]      					=    tokenize_kwargs

       snake_case    :      List[Any]      					=    {}
       if return_tensors is not None:
           snake_case    :      Tuple      					=    return_tensors

       return preprocess_params, {}, postprocess_params







   def  lowerCamelCase		(	self						,	UpperCamelCase__						,	**UpperCamelCase__						)	->		Dict[str, GenericTensor]:

       '''simple docstring'''




       snake_case    :      List[Any]      					=    self.framework
       snake_case    :      str      					=    self.tokenizer(UpperCamelCase__						,	return_tensors=UpperCamelCase__						,	**UpperCamelCase__						)
       return model_inputs







   def  lowerCamelCase		(	self						,	UpperCamelCase__						)	->		Tuple:

       '''simple docstring'''




       snake_case    :      int      					=    self.model(**UpperCamelCase__						)
       return model_outputs







   def  lowerCamelCase		(	self						,	UpperCamelCase__						,	UpperCamelCase__=False						)	->		Union[str, Any]:

       '''simple docstring'''




       if return_tensors:
           return model_outputs[0]
       if self.framework == "pt":
           return model_outputs[0].tolist()
       elif self.framework == "tf":
           return model_outputs[0].numpy().tolist()







   def __call__(	self						,	*UpperCamelCase__						,	**UpperCamelCase__						)	->		Union[str, Any]:

       '''simple docstring'''




       return super().__call__(*UpperCamelCase__						,	**UpperCamelCase__						)





