



from typing import List, Optional, Union

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


a_      :      Tuple    =     logging.get_logger(__name__)

a_      :      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    __UpperCamelCase			(       _lowercase				):

 """simple docstring"""



 _lowercase   :    Any      						=					'''informer'''
 _lowercase   :    List[Any]      						=					{
     '''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 = None		,				SCREAMING_SNAKE_CASE = "mean"		,				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 = 3_2		,				SCREAMING_SNAKE_CASE = 3_2		,				SCREAMING_SNAKE_CASE = 2		,				SCREAMING_SNAKE_CASE = 2		,				SCREAMING_SNAKE_CASE = 2		,				SCREAMING_SNAKE_CASE = 2		,				SCREAMING_SNAKE_CASE = True		,				SCREAMING_SNAKE_CASE = "gelu"		,				SCREAMING_SNAKE_CASE = 0.05		,				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 = "prob"		,				SCREAMING_SNAKE_CASE = 5		,				SCREAMING_SNAKE_CASE = True		,				**SCREAMING_SNAKE_CASE		,				) ->			Tuple:
  # time series specific configuration
  a__												= prediction_length
  a__												= context_length or prediction_length
  a__												= distribution_output
  a__												= loss
  a__												= input_size
  a__												= num_time_features
  a__												= lags_sequence if lags_sequence is not None else [1, 2, 3, 4, 5, 6, 7]
  a__												= scaling
  a__												= num_dynamic_real_features
  a__												= num_static_real_features
  a__												= num_static_categorical_features

  # set cardinality
  if cardinality 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]

  # set embedding_dimension
  if embedding_dimension 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

  # Informer
  a__												= attention_type
  a__												= sampling_factor
  a__												= distil

  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
  )










import logging
import os

from .state import PartialState
class    __UpperCamelCase			(       logging.LoggerAdapter				):

 """simple docstring"""



 @staticmethod
 def 						_UpperCAmelCase       (	SCREAMING_SNAKE_CASE      ) ->			Optional[Any]:
  a__												= PartialState()
  return not main_process_only or (main_process_only and state.is_main_process)



 def 						_UpperCAmelCase       (	self		,				SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE		,				*SCREAMING_SNAKE_CASE		,				**SCREAMING_SNAKE_CASE      ) ->			Optional[int]:
  if PartialState._shared_state == {}:
   raise RuntimeError(
       '''You must initialize the accelerate state by calling either `PartialState()` or `Accelerator()` before using the logging utility.'''      )
  a__												= kwargs.pop('''main_process_only'''		,				SCREAMING_SNAKE_CASE      )
  a__												= kwargs.pop('''in_order'''		,				SCREAMING_SNAKE_CASE      )

  if self.isEnabledFor(SCREAMING_SNAKE_CASE      ):
   if self._should_log(SCREAMING_SNAKE_CASE      ):
    a__							,			a__												= self.process(SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE      )
    self.logger.log(SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE		,				*SCREAMING_SNAKE_CASE		,				**SCREAMING_SNAKE_CASE      )

   elif in_order:
    a__												= PartialState()
    for i in range(state.num_processes      ):
     if i == state.process_index:
      a__							,			a__												= self.process(SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE      )
      self.logger.log(SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE		,				*SCREAMING_SNAKE_CASE		,				**SCREAMING_SNAKE_CASE      )
     state.wait_for_everyone()






def     __a					(		__UpperCAmelCase							,  __UpperCAmelCase = None       ):
 if log_level is None:
  a__												= os.environ.get('''ACCELERATE_LOG_LEVEL'''							,  __UpperCAmelCase       )
 a__												= logging.getLogger(__UpperCAmelCase       )
 if log_level is not None:
  logger.setLevel(log_level.upper()       )
  logger.root.setLevel(log_level.upper()       )
 return MultiProcessAdapter(__UpperCAmelCase							,  {}       )





