





from typing import List, Optional

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


lowerCAmelCase_    =    logging.get_logger(__name__)

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



class  __lowerCAmelCase	(      SCREAMING_SNAKE_CASE__					):
			lowerCamelCase_					:					List[Any]	      =				'autoformer'
			lowerCamelCase_					:					Dict	      =				{
			    'hidden_size': 'd_model',
			    'num_attention_heads': 'encoder_attention_heads',
			    'num_hidden_layers': 'encoder_layers',
			}






			def __init__(self ,							__magic_name__ = None ,							__magic_name__ = None ,							__magic_name__ = "student_t" ,							__magic_name__ = "nll" ,							__magic_name__ = 1 ,							__magic_name__ = [1, 2, 3, 4, 5, 6, 7] ,							__magic_name__ = True ,							__magic_name__ = 0 ,							__magic_name__ = 0 ,							__magic_name__ = 0 ,							__magic_name__ = 0 ,							__magic_name__ = None ,							__magic_name__ = None ,							__magic_name__ = 64 ,							__magic_name__ = 2 ,							__magic_name__ = 2 ,							__magic_name__ = 2 ,							__magic_name__ = 2 ,							__magic_name__ = 32 ,							__magic_name__ = 32 ,							__magic_name__ = "gelu" ,							__magic_name__ = 0.1 ,							__magic_name__ = 0.1 ,							__magic_name__ = 0.1 ,							__magic_name__ = 0.1 ,							__magic_name__ = 0.1 ,							__magic_name__ = 100 ,							__magic_name__ = 0.02 ,							__magic_name__ = True ,							__magic_name__=True ,							__magic_name__ = 10 ,							__magic_name__ = 25 ,							__magic_name__ = 3 ,							**__magic_name__ ,							)					->       List[Any]:


							'''simple docstring'''



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

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

							snake_case_						:   Tuple           =  dropout
							snake_case_						:   Any           =  attention_dropout
							snake_case_						:   Union[str, Any]           =  activation_dropout
							snake_case_						:   Tuple           =  encoder_layerdrop
							snake_case_						:   Optional[int]           =  decoder_layerdrop

							snake_case_						:   Optional[Any]           =  activation_function
							snake_case_						:   Optional[int]           =  init_std

							snake_case_						:   List[Any]           =  use_cache

							# Autoformer
							snake_case_						:   List[Any]           =  label_length
							snake_case_						:   Any           =  moving_average
							snake_case_						:   Optional[int]           =  autocorrelation_factor

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






			@property
			def       lowerCamelCase  (self   )					->       Union[str, Any]:


							'''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
							)







from collections.abc import Iterator, MutableMapping
from dataclasses import dataclass
from typing import Generic, TypeVar

lowerCAmelCase_    =    TypeVar('''KEY''')
lowerCAmelCase_    =    TypeVar('''VAL''')



@dataclass(frozen=_a,					slots=_a					)
class  __lowerCAmelCase	(      Generic[KEY, VAL]					):
			lowerCamelCase_					:					KEY
			lowerCamelCase_					:					VAL




class  __lowerCAmelCase	(      _Item					):






			def __init__(self   )					->       None:


							'''simple docstring'''



							super().__init__(__magic_name__ ,							__magic_name__   )






			def __bool__(self   )					->       bool:


							'''simple docstring'''



							return False




lowerCAmelCase_    =    _DeletedItem()



class  __lowerCAmelCase	(      MutableMapping[KEY, VAL]					):






			def __init__(self ,							__magic_name__ = 8 ,							__magic_name__ = 0.75   )					->       None:


							'''simple docstring'''



							snake_case_						:   List[Any]           =  initial_block_size
							snake_case_						:   list[_Item | None]           =  [None] * initial_block_size
							assert 0.0 < capacity_factor < 1.0
							snake_case_						:   List[str]           =  capacity_factor
							snake_case_						:   int           =  0






			def       lowerCamelCase  (self ,							__magic_name__   )					->       int:


							'''simple docstring'''



							return hash(__magic_name__   ) % len(self._buckets   )






			def       lowerCamelCase  (self ,							__magic_name__   )					->       int:


							'''simple docstring'''



							return (ind + 1) % len(self._buckets   )






			def       lowerCamelCase  (self ,							__magic_name__ ,							__magic_name__ ,							__magic_name__   )					->       bool:


							'''simple docstring'''



							snake_case_						:   Optional[int]           =  self._buckets[ind]
							if not stored:
											snake_case_						:   Optional[Any]           =  _Item(__magic_name__ ,							__magic_name__   )
											self._len += 1
											return True
							elif stored.key == key:
											snake_case_						:   List[Any]           =  _Item(__magic_name__ ,							__magic_name__   )
											return True
							else:
											return False






			def       lowerCamelCase  (self   )					->       bool:


							'''simple docstring'''



							snake_case_						:   Any           =  len(self._buckets   ) * self._capacity_factor
							return len(self   ) >= int(__magic_name__   )






			def       lowerCamelCase  (self   )					->       bool:


							'''simple docstring'''



							if len(self._buckets   ) <= self._initial_block_size:
											return False
							snake_case_						:   int           =  len(self._buckets   ) * self._capacity_factor / 2
							return len(self   ) < limit






			def       lowerCamelCase  (self ,							__magic_name__   )					->       None:


							'''simple docstring'''



							snake_case_						:   List[str]           =  self._buckets
							snake_case_						:   int           =  [None] * new_size
							snake_case_						:   Optional[int]           =  0
							for item in old_buckets:
											if item:
															self._add_item(item.key ,							item.val   )






			def       lowerCamelCase  (self   )					->       None:


							'''simple docstring'''



							self._resize(len(self._buckets   ) * 2   )






			def       lowerCamelCase  (self   )					->       None:


							'''simple docstring'''



							self._resize(len(self._buckets   ) // 2   )






			def       lowerCamelCase  (self ,							__magic_name__   )					->       Iterator[int]:


							'''simple docstring'''



							snake_case_						:   Dict           =  self._get_bucket_index(__magic_name__   )
							for _ in range(len(self._buckets   )   ):
											yield ind
											snake_case_						:   Tuple           =  self._get_next_ind(__magic_name__   )






			def       lowerCamelCase  (self ,							__magic_name__ ,							__magic_name__   )					->       None:


							'''simple docstring'''



							for ind in self._iterate_buckets(__magic_name__   ):
											if self._try_set(__magic_name__ ,							__magic_name__ ,							__magic_name__   ):
															break






			def __setitem__(self ,							__magic_name__ ,							__magic_name__   )					->       None:


							'''simple docstring'''



							if self._is_full():
											self._size_up()

							self._add_item(__magic_name__ ,							__magic_name__   )






			def __delitem__(self ,							__magic_name__   )					->       None:


							'''simple docstring'''



							for ind in self._iterate_buckets(__magic_name__   ):
											snake_case_						:   Optional[Any]           =  self._buckets[ind]
											if item is None:
															raise KeyError(__magic_name__   )
											if item is _deleted:
															continue
											if item.key == key:
															snake_case_						:   Union[str, Any]           =  _deleted
															self._len -= 1
															break
							if self._is_sparse():
											self._size_down()






			def __getitem__(self ,							__magic_name__   )					->       VAL:


							'''simple docstring'''



							for ind in self._iterate_buckets(__magic_name__   ):
											snake_case_						:   List[Any]           =  self._buckets[ind]
											if item is None:
															break
											if item is _deleted:
															continue
											if item.key == key:
															return item.val
							raise KeyError(__magic_name__   )






			def __len__(self   )					->       int:


							'''simple docstring'''



							return self._len






			def __iter__(self   )					->       Iterator[KEY]:


							'''simple docstring'''



							yield from (item.key for item in self._buckets if item)






			def __repr__(self   )					->       str:


							'''simple docstring'''



							snake_case_						:   List[str]           =  ''' ,'''.join(
							    F'''{item.key}: {item.val}''' for item in self._buckets if item   )
							return F'''HashMap({val_string})'''
