from typing import List, Optional, Union

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


__magic_name__								=					logging.get_logger(__name__)

__magic_name__								=					{
    '''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     _A   (    __UpperCamelCase							):
  SCREAMING_SNAKE_CASE_	:	Any						="informer"
  SCREAMING_SNAKE_CASE_	:	Tuple						={
      "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_ = 64   ,				SCREAMING_SNAKE_CASE_ = 32   ,				SCREAMING_SNAKE_CASE_ = 32   ,				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_ = 100   ,				SCREAMING_SNAKE_CASE_ = 0.02   ,				SCREAMING_SNAKE_CASE_=True   ,				SCREAMING_SNAKE_CASE_ = "prob"   ,				SCREAMING_SNAKE_CASE_ = 5   ,				SCREAMING_SNAKE_CASE_ = True   ,				**SCREAMING_SNAKE_CASE_   ,				)		->      List[str]:





       '''simple docstring'''





       UpperCamelCase__										=      prediction_length
       UpperCamelCase__										=      context_length or prediction_length
       UpperCamelCase__										=      distribution_output
       UpperCamelCase__										=      loss
       UpperCamelCase__										=      input_size
       UpperCamelCase__										=      num_time_features
       UpperCamelCase__										=      lags_sequence if lags_sequence is not None else [1, 2, 3, 4, 5, 6, 7]
       UpperCamelCase__										=      scaling
       UpperCamelCase__										=      num_dynamic_real_features
       UpperCamelCase__										=      num_static_real_features
       UpperCamelCase__										=      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`'''	)
            UpperCamelCase__										=      cardinality
       else:
            UpperCamelCase__										=      [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`'''	)
            UpperCamelCase__										=      embedding_dimension
       else:
            UpperCamelCase__										=      [min(50   ,				(cat + 1) // 2	) for cat in self.cardinality]

       UpperCamelCase__										=      num_parallel_samples

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

       UpperCamelCase__										=      dropout
       UpperCamelCase__										=      attention_dropout
       UpperCamelCase__										=      activation_dropout
       UpperCamelCase__										=      encoder_layerdrop
       UpperCamelCase__										=      decoder_layerdrop

       UpperCamelCase__										=      activation_function
       UpperCamelCase__										=      init_std

       UpperCamelCase__										=      use_cache

       # Informer
       UpperCamelCase__										=      attention_type
       UpperCamelCase__										=      sampling_factor
       UpperCamelCase__										=      distil

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






  @property
  def 		_a					(self	)		->      int:





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




import math

import tensorflow as tf
from packaging import version







def  __UpperCamelCase    (						A							):
     UpperCamelCase__										=      tf.convert_to_tensor(A							)
     UpperCamelCase__										=      0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0							) ,							x.dtype							)							))

     return x * cdf







def  __UpperCamelCase    (						A							):
     UpperCamelCase__										=      tf.convert_to_tensor(A							)
     UpperCamelCase__										=      tf.cast(math.pi ,							x.dtype							)
     UpperCamelCase__										=      tf.cast(0.04_47_15 ,							x.dtype							)
     UpperCamelCase__										=      0.5 * (1.0 + tf.tanh(tf.sqrt(2.0 / pi							) * (x + coeff * tf.pow(A ,							3							))							))

     return x * cdf







def  __UpperCamelCase    (						A							):
     UpperCamelCase__										=      tf.convert_to_tensor(A							)

     return x * tf.tanh(tf.math.softplus(A							)							)







def  __UpperCamelCase    (						A							):
     UpperCamelCase__										=      tf.convert_to_tensor(A							)
     UpperCamelCase__										=      tf.cast(0.04_47_15 ,							x.dtype							)
     UpperCamelCase__										=      tf.cast(0.79_78_84_56_08 ,							x.dtype							)

     return 0.5 * x * (1.0 + tf.tanh(x * coeffa * (1.0 + coeffa * x * x)							))







def  __UpperCamelCase    (						A							):
     UpperCamelCase__										=      tf.convert_to_tensor(A							)
     UpperCamelCase__										=      tf.cast(1.7_02 ,							x.dtype							)
     return x * tf.math.sigmoid(coeff * x							)







def  __UpperCamelCase    (						A							):
     return tf.clip_by_value(_gelu(A							) ,							-10 ,							10							)







def  __UpperCamelCase    (						A ,							A=-1							):
     UpperCamelCase__						,       UpperCamelCase__										=      tf.split(A ,							2 ,							axis=A							)
     return a * tf.math.sigmoid(A							)


if version.parse(tf.version.VERSION) >= version.parse('''2.4'''):







     def  __UpperCamelCase    (						A							):
          return tf.keras.activations.gelu(A ,							approximate=A							)

     __magic_name__								=tf.keras.activations.gelu



     __magic_name__								=approximate_gelu_wrap
else:
     __magic_name__								=_gelu
     __magic_name__								=_gelu_new


__magic_name__								={
    '''gelu''': gelu,
    '''gelu_10''': gelu_aa,
    '''gelu_fast''': gelu_fast,
    '''gelu_new''': gelu_new,
    '''glu''': glu,
    '''mish''': mish,
    '''quick_gelu''': quick_gelu,
    '''relu''': tf.keras.activations.relu,
    '''sigmoid''': tf.keras.activations.sigmoid,
    '''silu''': tf.keras.activations.swish,
    '''swish''': tf.keras.activations.swish,
    '''tanh''': tf.keras.activations.tanh,
}







def  __UpperCamelCase    (						A							):
     if activation_string in ACTaFN:
          return ACTaFN[activation_string]
     else:
          raise KeyError(f"function {activation_string} not found in ACT2FN mapping {list(ACTaFN.keys()							)}"							)



