
from typing import List, Optional

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


__snake_case				      =    logging.get_logger(__name__)

__snake_case				      =    {
    '''huggingface/autoformer-tourism-monthly''': '''https://huggingface.co/huggingface/autoformer-tourism-monthly/resolve/main/config.json''',
}




class 		lowercase__    (		lowerCAmelCase__    ):
	A__       :  Optional[int]										="""autoformer"""
	A__       :  Tuple										={
	    """hidden_size""": """d_model""",
	    """num_attention_heads""": """encoder_attention_heads""",
	    """num_hidden_layers""": """encoder_layers""",
	}
	def __init__(     self				:  int			,  UpperCAmelCase_				:  List[str] = None			,  UpperCAmelCase_				:  int = None			,  UpperCAmelCase_				:  Optional[Any] = "student_t"			,  UpperCAmelCase_				:  List[str] = "nll"			,  UpperCAmelCase_				:  List[Any] = 1			,  UpperCAmelCase_				:  Tuple = [1, 2, 3, 4, 5, 6, 7]			,  UpperCAmelCase_				:  Union[str, Any] = True			,  UpperCAmelCase_				:  Dict = 0			,  UpperCAmelCase_				:  Any = 0			,  UpperCAmelCase_				:  List[Any] = 0			,  UpperCAmelCase_				:  Optional[int] = 0			,  UpperCAmelCase_				:  List[Any] = None			,  UpperCAmelCase_				:  Dict = None			,  UpperCAmelCase_				:  List[Any] = 64			,  UpperCAmelCase_				:  Any = 2			,  UpperCAmelCase_				:  int = 2			,  UpperCAmelCase_				:  Optional[int] = 2			,  UpperCAmelCase_				:  int = 2			,  UpperCAmelCase_				:  Optional[int] = 32			,  UpperCAmelCase_				:  List[str] = 32			,  UpperCAmelCase_				:  Optional[int] = "gelu"			,  UpperCAmelCase_				:  Optional[Any] = 0.1			,  UpperCAmelCase_				:  Union[str, Any] = 0.1			,  UpperCAmelCase_				:  Optional[Any] = 0.1			,  UpperCAmelCase_				:  Any = 0.1			,  UpperCAmelCase_				:  int = 0.1			,  UpperCAmelCase_				:  Optional[int] = 100			,  UpperCAmelCase_				:  Any = 0.02			,  UpperCAmelCase_				:  int = True			,  UpperCAmelCase_				:  Dict=True			,  UpperCAmelCase_				:  Optional[Any] = 10			,  UpperCAmelCase_				:  Union[str, Any] = 25			,  UpperCAmelCase_				:  List[Any] = 3			,  **UpperCAmelCase_				:  Optional[Any]			,  ):
						SCREAMING_SNAKE_CASE__						=					prediction_length
						SCREAMING_SNAKE_CASE__						=					context_length if context_length is not None else 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 is not None and num_static_categorical_features > 0:
											if len(snake_case_				) != 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 is not None and num_static_categorical_features > 0:
											if len(snake_case_				) != 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(self.lags_sequence				) + 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

						# Autoformer
						SCREAMING_SNAKE_CASE__						=					label_length
						SCREAMING_SNAKE_CASE__						=					moving_average
						SCREAMING_SNAKE_CASE__						=					autocorrelation_factor

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





	@property
	def 	A_							(     self				:  str				):
						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
						)









from typing import Optional

from .. import Features, NamedSplit
from ..packaged_modules.text.text import Text
from ..utils.typing import NestedDataStructureLike, PathLike
from .abc import AbstractDatasetReader
class 						lowerCamelCase_							(					lowerCAmelCase__					):



					'''simple docstring'''







					def __init__(					self			,							snake_case_			,							snake_case_ = None			,							snake_case_ = None			,							snake_case_ = None			,							snake_case_ = False			,							snake_case_ = False			,							snake_case_ = None			,							**snake_case_			,							) ->      Dict:







								'''simple docstring'''

								super().__init__(
								    snake_case_			,							split=snake_case_			,							features=snake_case_			,							cache_dir=snake_case_			,							keep_in_memory=snake_case_			,							streaming=snake_case_			,							num_proc=snake_case_			,							**snake_case_			,							)
								__lowercase			       = path_or_paths if isinstance(snake_case_			,							snake_case_    ) else {self.split: path_or_paths}
								__lowercase			       = Text(
								    cache_dir=snake_case_			,							data_files=snake_case_			,							features=snake_case_			,							**snake_case_			,							)






					def A   (					self    ) ->      int:







								'''simple docstring'''

								if self.streaming:
											__lowercase			       = self.builder.as_streaming_dataset(split=self.split    )
								# Build regular (map-style) dataset
								else:
											__lowercase			       = None
											__lowercase			       = None
											__lowercase			       = None
											__lowercase			       = None

											self.builder.download_and_prepare(
											    download_config=snake_case_			,							download_mode=snake_case_			,							verification_mode=snake_case_			,							base_path=snake_case_			,							num_proc=self.num_proc			,							)
											__lowercase			       = self.builder.as_dataset(
											    split=self.split			,							verification_mode=snake_case_			,							in_memory=self.keep_in_memory    )
								return dataset


