





"""simple docstring"""




import torch

from diffusers import DiffusionPipeline

class  _UpperCAmelCase  (   UpperCAmelCase__		):



      '''simple docstring'''

      def __init__(     self					,      snake_case_					,      snake_case_  ):

        """simple docstring"""

        super().__init__()

        self.register_modules(unet=snake_case_					,      scheduler=snake_case_  )

      def __call__(     self  ):

        """simple docstring"""

        A_  :       Optional[Any]										=  torch.randn(
            (1, self.unet.config.in_channels, self.unet.config.sample_size, self.unet.config.sample_size)					,      )
        A_  :       List[str]										=  1

        A_  :       List[str]										=  self.unet(snake_case_					,      snake_case_  ).sample
        A_  :       Optional[int]										=  self.scheduler.step(snake_case_					,      snake_case_					,      snake_case_  ).prev_sample

        A_  :       List[Any]										=  scheduler_output - scheduler_output + torch.ones_like(snake_case_  )

        return result






"""simple docstring"""




from typing import List, Optional, Union

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


lowerCamelCase_     :						Union[str, Any]						=					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  _UpperCAmelCase  (   UpperCAmelCase__		):



      '''simple docstring'''
      lowercase_      : Tuple	    =   """informer"""
      lowercase_      : str	    =   {
          """hidden_size""": """d_model""",
          """num_attention_heads""": """encoder_attention_heads""",
          """num_hidden_layers""": """encoder_layers""",
      }

      def __init__(     self					,      snake_case_ = None					,      snake_case_ = None					,      snake_case_ = "student_t"					,      snake_case_ = "nll"					,      snake_case_ = 1					,      snake_case_ = None					,      snake_case_ = "mean"					,      snake_case_ = 0					,      snake_case_ = 0					,      snake_case_ = 0					,      snake_case_ = 0					,      snake_case_ = None					,      snake_case_ = None					,      snake_case_ = 6_4					,      snake_case_ = 3_2					,      snake_case_ = 3_2					,      snake_case_ = 2					,      snake_case_ = 2					,      snake_case_ = 2					,      snake_case_ = 2					,      snake_case_ = True					,      snake_case_ = "gelu"					,      snake_case_ = 0.05					,      snake_case_ = 0.1					,      snake_case_ = 0.1					,      snake_case_ = 0.1					,      snake_case_ = 0.1					,      snake_case_ = 1_0_0					,      snake_case_ = 0.02					,      snake_case_=True					,      snake_case_ = "prob"					,      snake_case_ = 5					,      snake_case_ = True					,      **snake_case_					,      ):

        """simple docstring"""

        A_  :       str										=  prediction_length
        A_  :       List[Any]										=  context_length or prediction_length
        A_  :       str										=  distribution_output
        A_  :       Dict										=  loss
        A_  :       Any										=  input_size
        A_  :       Union[str, Any]										=  num_time_features
        A_  :       Optional[Any]										=  lags_sequence if lags_sequence is not None else [1, 2, 3, 4, 5, 6, 7]
        A_  :       List[Any]										=  scaling
        A_  :       Tuple										=  num_dynamic_real_features
        A_  :       Any										=  num_static_real_features
        A_  :       str										=  num_static_categorical_features

        # set cardinality
        if cardinality and num_static_categorical_features > 0:
          if len(snake_case_  ) != num_static_categorical_features:
            raise ValueError(
                'The cardinality should be a list of the same length as `num_static_categorical_features`'  )
          A_  :       Optional[int]										=  cardinality
        else:
          A_  :       Optional[Any]										=  [0]

        # set embedding_dimension
        if embedding_dimension and num_static_categorical_features > 0:
          if len(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_  :       Any										=  embedding_dimension
        else:
          A_  :       Optional[Any]										=  [min(5_0					,      (cat + 1) // 2  ) for cat in self.cardinality]

        A_  :       int										=  num_parallel_samples

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

        A_  :       List[Any]										=  dropout
        A_  :       str										=  attention_dropout
        A_  :       Tuple										=  activation_dropout
        A_  :       List[str]										=  encoder_layerdrop
        A_  :       List[str]										=  decoder_layerdrop

        A_  :       str										=  activation_function
        A_  :       Optional[int]										=  init_std

        A_  :       List[Any]										=  use_cache

        # Informer
        A_  :       Tuple										=  attention_type
        A_  :       List[Any]										=  sampling_factor
        A_  :       Optional[int]										=  distil

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

      @property
      def 					lowerCamelCase_			(     self  ):

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