


'''simple docstring'''

from typing import List, Optional, Union

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


lowerCAmelCase :Tuple             =     logging.get_logger(__name__)

lowerCAmelCase :Optional[Any]             =     {
    'huggingface/informer-tourism-monthly': (
        'https://huggingface.co/huggingface/informer-tourism-monthly/resolve/main/config.json'
    ),
    # See all Informer models at https://huggingface.co/models?filter=informer
}
class _lowerCamelCase			(		_lowercase				):



		'''simple docstring'''







		A_      :     Any        =							'''informer'''
		A_      :     List[Any]        =							{
		    '''hidden_size''': '''d_model''',
		    '''num_attention_heads''': '''encoder_attention_heads''',
		    '''num_hidden_layers''': '''encoder_layers''',
		}







		def __init__(   self						:		List[str]    ,	_A						:		Tuple = None    ,	_A						:		str = None    ,	_A						:		Any = "student_t"    ,	_A						:		int = "nll"    ,	_A						:		Optional[Any] = 1    ,	_A						:		List[Any] = None    ,	_A						:		List[str] = "mean"    ,	_A						:		str = 0    ,	_A						:		Optional[int] = 0    ,	_A						:		List[str] = 0    ,	_A						:		Any = 0    ,	_A						:		Any = None    ,	_A						:		Optional[Any] = None    ,	_A						:		int = 64    ,	_A						:		Any = 32    ,	_A						:		List[str] = 32    ,	_A						:		Union[str, Any] = 2    ,	_A						:		str = 2    ,	_A						:		int = 2    ,	_A						:		Dict = 2    ,	_A						:		Any = True    ,	_A						:		Any = "gelu"    ,	_A						:		Optional[Any] = 0.05    ,	_A						:		Dict = 0.1    ,	_A						:		Union[str, Any] = 0.1    ,	_A						:		List[Any] = 0.1    ,	_A						:		List[Any] = 0.1    ,	_A						:		Union[str, Any] = 100    ,	_A						:		List[Any] = 0.02    ,	_A						:		int=True    ,	_A						:		List[str] = "prob"    ,	_A						:		int = 5    ,	_A						:		int = True    ,	**_A						:		Optional[Any]    ,	)    ->					Tuple:
			# time series specific configuration
			__magic_name__			:       Union[str, Any]	      =	prediction_length
			__magic_name__			:       Union[str, Any]	      =	context_length or prediction_length
			__magic_name__			:       Union[str, Any]	      =	distribution_output
			__magic_name__			:       str	      =	loss
			__magic_name__			:       Dict	      =	input_size
			__magic_name__			:       Any	      =	num_time_features
			__magic_name__			:       Optional[Any]	      =	lags_sequence if lags_sequence is not None else [1, 2, 3, 4, 5, 6, 7]
			__magic_name__			:       Union[str, Any]	      =	scaling
			__magic_name__			:       Optional[Any]	      =	num_dynamic_real_features
			__magic_name__			:       Tuple	      =	num_static_real_features
			__magic_name__			:       List[Any]	      =	num_static_categorical_features

			# set cardinality
			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`'     )
				__magic_name__			:       Union[str, Any]	      =	cardinality
			else:
				__magic_name__			:       Any	      =	[0]

			# set embedding_dimension
			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`'     )
				__magic_name__			:       int	      =	embedding_dimension
			else:
				__magic_name__			:       List[Any]	      =	[min(50    ,	(cat + 1) // 2     ) for cat in self.cardinality]

			__magic_name__			:       Optional[int]	      =	num_parallel_samples

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

			__magic_name__			:       List[Any]	      =	dropout
			__magic_name__			:       List[Any]	      =	attention_dropout
			__magic_name__			:       Dict	      =	activation_dropout
			__magic_name__			:       int	      =	encoder_layerdrop
			__magic_name__			:       Union[str, Any]	      =	decoder_layerdrop

			__magic_name__			:       List[str]	      =	activation_function
			__magic_name__			:       Optional[int]	      =	init_std

			__magic_name__			:       Any	      =	use_cache

			# Informer
			__magic_name__			:       Optional[int]	      =	attention_type
			__magic_name__			:       Optional[Any]	      =	sampling_factor
			__magic_name__			:       Optional[int]	      =	distil

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







		@property
		def   __lowerCAmelCase						(   self						:		int     )    ->					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       )





