
from typing import List, Optional

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


UpperCAmelCase__		:     Tuple     			=      logging.get_logger(__name__)

UpperCAmelCase__		:     Optional[int]     			=      {
    'huggingface/autoformer-tourism-monthly': 'https://huggingface.co/huggingface/autoformer-tourism-monthly/resolve/main/config.json',
}






class UpperCAmelCase   (						SCREAMING_SNAKE_CASE__   ):





   '''simple docstring'''
   __UpperCamelCase		:    Any 				=    '''autoformer'''
   __UpperCamelCase		:    Optional[Any] 				=    {
       '''hidden_size''': '''d_model''',
       '''num_attention_heads''': '''encoder_attention_heads''',
       '''num_hidden_layers''': '''encoder_layers''',
   }


   def __init__(					self     :							Dict			,			lowerCAmelCase_     :							Optional[int] = None			,			lowerCAmelCase_     :							Optional[int] = None			,			lowerCAmelCase_     :							str = "student_t"			,			lowerCAmelCase_     :							str = "nll"			,			lowerCAmelCase_     :							int = 1			,			lowerCAmelCase_     :							List[int] = [1, 2, 3, 4, 5, 6, 7]			,			lowerCAmelCase_     :							bool = True			,			lowerCAmelCase_     :							int = 0			,			lowerCAmelCase_     :							int = 0			,			lowerCAmelCase_     :							int = 0			,			lowerCAmelCase_     :							int = 0			,			lowerCAmelCase_     :							Optional[List[int]] = None			,			lowerCAmelCase_     :							Optional[List[int]] = None			,			lowerCAmelCase_     :							int = 6_4			,			lowerCAmelCase_     :							int = 2			,			lowerCAmelCase_     :							int = 2			,			lowerCAmelCase_     :							int = 2			,			lowerCAmelCase_     :							int = 2			,			lowerCAmelCase_     :							int = 3_2			,			lowerCAmelCase_     :							int = 3_2			,			lowerCAmelCase_     :							str = "gelu"			,			lowerCAmelCase_     :							float = 0.1			,			lowerCAmelCase_     :							float = 0.1			,			lowerCAmelCase_     :							float = 0.1			,			lowerCAmelCase_     :							float = 0.1			,			lowerCAmelCase_     :							float = 0.1			,			lowerCAmelCase_     :							int = 1_0_0			,			lowerCAmelCase_     :							float = 0.02			,			lowerCAmelCase_     :							bool = True			,			lowerCAmelCase_     :							Union[str, Any]=True			,			lowerCAmelCase_     :							int = 1_0			,			lowerCAmelCase_     :							int = 2_5			,			lowerCAmelCase_     :							int = 3			,			**lowerCAmelCase_     :							List[str]			,			):

      """simple docstring"""
      # time series specific configuration
      _A:  Optional[int]					=       prediction_length
      _A:  int					=       context_length if context_length is not None else prediction_length
      _A:  str					=       distribution_output
      _A:  Optional[int]					=       loss
      _A:  str					=       input_size
      _A:  List[Any]					=       num_time_features
      _A:  Optional[int]					=       lags_sequence
      _A:  int					=       scaling
      _A:  List[str]					=       num_dynamic_real_features
      _A:  Union[str, Any]					=       num_static_real_features
      _A:  Tuple					=       num_static_categorical_features
      if cardinality is not None and num_static_categorical_features > 0:
         if len(lowerCAmelCase_     ) != num_static_categorical_features:
            raise ValueError(
                '''The cardinality should be a list of the same length as `num_static_categorical_features`'''     )
         _A:  Union[str, Any]					=       cardinality
      else:
         _A:  List[str]					=       [0]
      if embedding_dimension is not None and num_static_categorical_features > 0:
         if len(lowerCAmelCase_     ) != num_static_categorical_features:
            raise ValueError(
                '''The embedding dimension should be a list of the same length as `num_static_categorical_features`'''     )
         _A:  List[Any]					=       embedding_dimension
      else:
         _A:  Tuple					=       [min(5_0			,			(cat + 1) // 2     ) for cat in self.cardinality]
      _A:  str					=       num_parallel_samples

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

      _A:  Optional[Any]					=       dropout
      _A:  str					=       attention_dropout
      _A:  List[Any]					=       activation_dropout
      _A:  str					=       encoder_layerdrop
      _A:  Optional[int]					=       decoder_layerdrop

      _A:  Dict					=       activation_function
      _A:  List[Any]					=       init_std

      _A:  Optional[int]					=       use_cache

      # Autoformer
      _A:  Dict					=       label_length
      _A:  Optional[Any]					=       moving_average
      _A:  Union[str, Any]					=       autocorrelation_factor

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


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





def   lowerCamelCase__							(					a		,		a      )      ->   str:
   if a < 0 or b < 0:
      raise ValueError('''the value of both inputs must be positive'''      )

   _A:  Union[str, Any]					=       str(bin(a      )      )[2:]  # remove the leading "0b"
   _A:  Union[str, Any]					=       str(bin(a      )      )[2:]  # remove the leading "0b"

   _A:  Optional[int]					=       max(len(a      )		,		len(a      )      )

   return "0b" + "".join(
       str(int(char_a != char_b      )      )
       for char_a, char_b in zip(a_binary.zfill(a      )		,		b_binary.zfill(a      )      )      )


if __name__ == "__main__":
   import doctest

   doctest.testmod()



