



from typing import List, Optional

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


a_      :      Any    =     logging.get_logger(__name__)

a_      :      List[str]    =     {
    'huggingface/autoformer-tourism-monthly': 'https://huggingface.co/huggingface/autoformer-tourism-monthly/resolve/main/config.json',
}
class    __UpperCamelCase			(       _lowercase				):

 """simple docstring"""



 _lowercase   :    int      						=					'''autoformer'''
 _lowercase   :    Optional[int]      						=					{
     '''hidden_size''': '''d_model''',
     '''num_attention_heads''': '''encoder_attention_heads''',
     '''num_hidden_layers''': '''encoder_layers''',
 }

 def __init__(	self		,				SCREAMING_SNAKE_CASE = None		,				SCREAMING_SNAKE_CASE = None		,				SCREAMING_SNAKE_CASE = "student_t"		,				SCREAMING_SNAKE_CASE = "nll"		,				SCREAMING_SNAKE_CASE = 1		,				SCREAMING_SNAKE_CASE = [1, 2, 3, 4, 5, 6, 7]		,				SCREAMING_SNAKE_CASE = True		,				SCREAMING_SNAKE_CASE = 0		,				SCREAMING_SNAKE_CASE = 0		,				SCREAMING_SNAKE_CASE = 0		,				SCREAMING_SNAKE_CASE = 0		,				SCREAMING_SNAKE_CASE = None		,				SCREAMING_SNAKE_CASE = None		,				SCREAMING_SNAKE_CASE = 6_4		,				SCREAMING_SNAKE_CASE = 2		,				SCREAMING_SNAKE_CASE = 2		,				SCREAMING_SNAKE_CASE = 2		,				SCREAMING_SNAKE_CASE = 2		,				SCREAMING_SNAKE_CASE = 3_2		,				SCREAMING_SNAKE_CASE = 3_2		,				SCREAMING_SNAKE_CASE = "gelu"		,				SCREAMING_SNAKE_CASE = 0.1		,				SCREAMING_SNAKE_CASE = 0.1		,				SCREAMING_SNAKE_CASE = 0.1		,				SCREAMING_SNAKE_CASE = 0.1		,				SCREAMING_SNAKE_CASE = 0.1		,				SCREAMING_SNAKE_CASE = 1_0_0		,				SCREAMING_SNAKE_CASE = 0.02		,				SCREAMING_SNAKE_CASE = True		,				SCREAMING_SNAKE_CASE=True		,				SCREAMING_SNAKE_CASE = 1_0		,				SCREAMING_SNAKE_CASE = 2_5		,				SCREAMING_SNAKE_CASE = 3		,				**SCREAMING_SNAKE_CASE		,				) ->			Union[str, Any]:
  # time series specific configuration
  a__												= prediction_length
  a__												= context_length if context_length is not None else prediction_length
  a__												= distribution_output
  a__												= loss
  a__												= input_size
  a__												= num_time_features
  a__												= lags_sequence
  a__												= scaling
  a__												= num_dynamic_real_features
  a__												= num_static_real_features
  a__												= num_static_categorical_features
  if cardinality is not None and num_static_categorical_features > 0:
   if len(SCREAMING_SNAKE_CASE      ) != num_static_categorical_features:
    raise ValueError(
        '''The cardinality should be a list of the same length as `num_static_categorical_features`'''      )
   a__												= cardinality
  else:
   a__												= [0]
  if embedding_dimension is not None and num_static_categorical_features > 0:
   if len(SCREAMING_SNAKE_CASE      ) != num_static_categorical_features:
    raise ValueError(
        '''The embedding dimension should be a list of the same length as `num_static_categorical_features`'''      )
   a__												= embedding_dimension
  else:
   a__												= [min(5_0		,				(cat + 1) // 2      ) for cat in self.cardinality]
  a__												= num_parallel_samples

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

  a__												= dropout
  a__												= attention_dropout
  a__												= activation_dropout
  a__												= encoder_layerdrop
  a__												= decoder_layerdrop

  a__												= activation_function
  a__												= init_std

  a__												= use_cache

  # Autoformer
  a__												= label_length
  a__												= moving_average
  a__												= autocorrelation_factor

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



 @property
 def 						_UpperCAmelCase       (	self      ) ->			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
  )










from typing import List, Optional, TypeVar

from .arrow_dataset import Dataset, _concatenate_map_style_datasets, _interleave_map_style_datasets
from .dataset_dict import DatasetDict, IterableDatasetDict
from .info import DatasetInfo
from .iterable_dataset import IterableDataset, _concatenate_iterable_datasets, _interleave_iterable_datasets
from .splits import NamedSplit
from .utils import logging
from .utils.py_utils import Literal


a_      :      Any    =     logging.get_logger(__name__)


a_      :      str    =     TypeVar('DatasetType', Dataset, IterableDataset)






def     __a					(		__UpperCAmelCase							,  __UpperCAmelCase = None							,  __UpperCAmelCase = None							,  __UpperCAmelCase = None							,  __UpperCAmelCase = None							,  __UpperCAmelCase = "first_exhausted"							,  ):
 from .arrow_dataset import Dataset
 from .iterable_dataset import IterableDataset

 if not datasets:
  raise ValueError('''Unable to interleave an empty list of datasets.'''       )
 for i, dataset in enumerate(__UpperCAmelCase       ):
  if not isinstance(__UpperCAmelCase							,  (Dataset, IterableDataset)       ):
   if isinstance(__UpperCAmelCase							,  (DatasetDict, IterableDatasetDict)       ):
    if not dataset:
     raise ValueError(
         f"Expected a list of Dataset objects or a list of IterableDataset objects, but element at position {i} "
         '''is an empty dataset dictionary.'''       )
    raise ValueError(
        f"Dataset at position {i} has at least one split: {list(__UpperCAmelCase       )}\n"
        f"Please pick one to interleave with the other datasets, for example: dataset['{next(iter(__UpperCAmelCase       )       )}']"       )
   raise ValueError(
       f"Expected a list of Dataset objects or a list of IterableDataset objects, but element at position {i} is a {type(__UpperCAmelCase       ).__name__}."       )
  if i == 0:
   a__							,			a__												= (
       (Dataset, IterableDataset) if isinstance(__UpperCAmelCase							,  __UpperCAmelCase       ) else (IterableDataset, Dataset)
   )
  elif not isinstance(__UpperCAmelCase							,  __UpperCAmelCase       ):
   raise ValueError(
       f"Unable to interleave a {dataset_type.__name__} (at position 0) with a {other_type.__name__} (at position {i}). Expected a list of Dataset objects or a list of IterableDataset objects."       )
 if stopping_strategy not in ["first_exhausted", "all_exhausted"]:
  raise ValueError(f"{stopping_strategy} is not supported. Please enter a valid stopping_strategy."       )
 if dataset_type is Dataset:
  return _interleave_map_style_datasets(
      __UpperCAmelCase							,  __UpperCAmelCase							,  __UpperCAmelCase							,  info=__UpperCAmelCase							,  split=__UpperCAmelCase							,  stopping_strategy=__UpperCAmelCase       )
 else:
  return _interleave_iterable_datasets(
      __UpperCAmelCase							,  __UpperCAmelCase							,  __UpperCAmelCase							,  info=__UpperCAmelCase							,  split=__UpperCAmelCase							,  stopping_strategy=__UpperCAmelCase       )






def     __a					(		__UpperCAmelCase							,  __UpperCAmelCase = None							,  __UpperCAmelCase = None							,  __UpperCAmelCase = 0							,  ):

 if not dsets:
  raise ValueError('''Unable to concatenate an empty list of datasets.'''       )
 for i, dataset in enumerate(__UpperCAmelCase       ):
  if not isinstance(__UpperCAmelCase							,  (Dataset, IterableDataset)       ):
   if isinstance(__UpperCAmelCase							,  (DatasetDict, IterableDatasetDict)       ):
    if not dataset:
     raise ValueError(
         f"Expected a list of Dataset objects or a list of IterableDataset objects, but element at position {i} "
         '''is an empty dataset dictionary.'''       )
    raise ValueError(
        f"Dataset at position {i} has at least one split: {list(__UpperCAmelCase       )}\n"
        f"Please pick one to interleave with the other datasets, for example: dataset['{next(iter(__UpperCAmelCase       )       )}']"       )
   raise ValueError(
       f"Expected a list of Dataset objects or a list of IterableDataset objects, but element at position {i} is a {type(__UpperCAmelCase       ).__name__}."       )
  if i == 0:
   a__							,			a__												= (
       (Dataset, IterableDataset) if isinstance(__UpperCAmelCase							,  __UpperCAmelCase       ) else (IterableDataset, Dataset)
   )
  elif not isinstance(__UpperCAmelCase							,  __UpperCAmelCase       ):
   raise ValueError(
       f"Unable to interleave a {dataset_type.__name__} (at position 0) with a {other_type.__name__} (at position {i}). Expected a list of Dataset objects or a list of IterableDataset objects."       )
 if dataset_type is Dataset:
  return _concatenate_map_style_datasets(__UpperCAmelCase							,  info=__UpperCAmelCase							,  split=__UpperCAmelCase							,  axis=__UpperCAmelCase       )
 else:
  return _concatenate_iterable_datasets(__UpperCAmelCase							,  info=__UpperCAmelCase							,  split=__UpperCAmelCase							,  axis=__UpperCAmelCase       )





