


'''simple docstring'''



from typing import List, Optional, Union

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


__UpperCAmelCase      :Optional[Any]			    =       logging.get_logger(__name__)

__UpperCAmelCase      :Union[str, 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      a    (		_a	):


     """simple docstring"""






     SCREAMING_SNAKE_CASE	:			Union[str, Any]							       =       "informer"
     SCREAMING_SNAKE_CASE	:			List[Any]							       =       {
         "hidden_size": "d_model",
         "num_attention_heads": "encoder_attention_heads",
         "num_hidden_layers": "encoder_layers",
     }

     def __init__(    self					:		Dict							,			snake_case					:		Optional[int] = None							,			snake_case					:		Optional[int] = None							,			snake_case					:		str = "student_t"							,			snake_case					:		str = "nll"							,			snake_case					:		int = 1							,			snake_case					:		List[int] = None							,			snake_case					:		Optional[Union[str, bool]] = "mean"							,			snake_case					:		int = 0							,			snake_case					:		int = 0							,			snake_case					:		int = 0							,			snake_case					:		int = 0							,			snake_case					:		Optional[List[int]] = None							,			snake_case					:		Optional[List[int]] = None							,			snake_case					:		int = 64							,			snake_case					:		int = 32							,			snake_case					:		int = 32							,			snake_case					:		int = 2							,			snake_case					:		int = 2							,			snake_case					:		int = 2							,			snake_case					:		int = 2							,			snake_case					:		bool = True							,			snake_case					:		str = "gelu"							,			snake_case					:		float = 0.05							,			snake_case					:		float = 0.1							,			snake_case					:		float = 0.1							,			snake_case					:		float = 0.1							,			snake_case					:		float = 0.1							,			snake_case					:		int = 100							,			snake_case					:		float = 0.02							,			snake_case					:		List[Any]=True							,			snake_case					:		str = "prob"							,			snake_case					:		int = 5							,			snake_case					:		bool = True							,			**snake_case					:		List[str]							,			)						->							Dict:
          # time series specific configuration
          __UpperCAmelCase     :			int  							=      prediction_length
          __UpperCAmelCase     :			Union[str, Any]  							=      context_length or prediction_length
          __UpperCAmelCase     :			Dict  							=      distribution_output
          __UpperCAmelCase     :			Dict  							=      loss
          __UpperCAmelCase     :			Dict  							=      input_size
          __UpperCAmelCase     :			List[Any]  							=      num_time_features
          __UpperCAmelCase     :			List[str]  							=      lags_sequence if lags_sequence is not None else [1, 2, 3, 4, 5, 6, 7]
          __UpperCAmelCase     :			Union[str, Any]  							=      scaling
          __UpperCAmelCase     :			Any  							=      num_dynamic_real_features
          __UpperCAmelCase     :			Any  							=      num_static_real_features
          __UpperCAmelCase     :			List[Any]  							=      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`'''      )
               __UpperCAmelCase     :			Optional[Any]  							=      cardinality
          else:
               __UpperCAmelCase     :			Union[str, 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`'''      )
               __UpperCAmelCase     :			List[Any]  							=      embedding_dimension
          else:
               __UpperCAmelCase     :			List[Any]  							=      [min(50							,			(cat + 1) // 2      ) for cat in self.cardinality]

          __UpperCAmelCase     :			int  							=      num_parallel_samples

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

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

          __UpperCAmelCase     :			Optional[Any]  							=      activation_function
          __UpperCAmelCase     :			Any  							=      init_std

          __UpperCAmelCase     :			Any  							=      use_cache

          # Informer
          __UpperCAmelCase     :			int  							=      attention_type
          __UpperCAmelCase     :			Optional[int]  							=      sampling_factor
          __UpperCAmelCase     :			str  							=      distil

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






     @property
     def 			lowerCamelCase__			(    self					:		Optional[Any]      )						->							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
          )



'''simple docstring'''



import os
import sys
import unittest


__UpperCAmelCase      :Optional[int]			    =       os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
sys.path.append(os.path.join(git_repo_path, "utils"))

import check_dummies  # noqa: E402
from check_dummies import create_dummy_files, create_dummy_object, find_backend, read_init  # noqa: E402


# Align TRANSFORMERS_PATH in check_dummies with the current path
__UpperCAmelCase      :Dict			    =       os.path.join(git_repo_path, "src", "diffusers")



class      a    (		unittest.TestCase	):


     """simple docstring"""






     def 			lowerCamelCase__			(    self					:		Any      )						->							int:
          __UpperCAmelCase     :			Optional[Any]  							=      find_backend('''    if not is_torch_available():'''      )
          self.assertEqual(snake_case							,			'''torch'''      )

          # backend_with_underscore = find_backend("    if not is_tensorflow_text_available():")
          # self.assertEqual(backend_with_underscore, "tensorflow_text")

          __UpperCAmelCase     :			Union[str, Any]  							=      find_backend('''    if not (is_torch_available() and is_transformers_available()):'''      )
          self.assertEqual(snake_case							,			'''torch_and_transformers'''      )

          # double_backend_with_underscore = find_backend(
          #    "    if not (is_sentencepiece_available() and is_tensorflow_text_available()):"
          # )
          # self.assertEqual(double_backend_with_underscore, "sentencepiece_and_tensorflow_text")

          __UpperCAmelCase     :			List[str]  							=      find_backend(
              '''    if not (is_torch_available() and is_transformers_available() and is_onnx_available()):'''      )
          self.assertEqual(snake_case							,			'''torch_and_transformers_and_onnx'''      )

     def 			lowerCamelCase__			(    self					:		Optional[int]      )						->							int:
          __UpperCAmelCase     :			Tuple  							=      read_init()
          # We don't assert on the exact list of keys to allow for smooth grow of backend-specific objects
          self.assertIn('''torch'''							,			snake_case      )
          self.assertIn('''torch_and_transformers'''							,			snake_case      )
          self.assertIn('''flax_and_transformers'''							,			snake_case      )
          self.assertIn('''torch_and_transformers_and_onnx'''							,			snake_case      )

          # Likewise, we can't assert on the exact content of a key
          self.assertIn('''UNet2DModel'''							,			objects['''torch''']      )
          self.assertIn('''FlaxUNet2DConditionModel'''							,			objects['''flax''']      )
          self.assertIn('''StableDiffusionPipeline'''							,			objects['''torch_and_transformers''']      )
          self.assertIn('''FlaxStableDiffusionPipeline'''							,			objects['''flax_and_transformers''']      )
          self.assertIn('''LMSDiscreteScheduler'''							,			objects['''torch_and_scipy''']      )
          self.assertIn('''OnnxStableDiffusionPipeline'''							,			objects['''torch_and_transformers_and_onnx''']      )

     def 			lowerCamelCase__			(    self					:		Optional[int]      )						->							List[Any]:
          __UpperCAmelCase     :			str  							=      create_dummy_object('''CONSTANT'''							,			'''\'torch\''''      )
          self.assertEqual(snake_case							,			'''\nCONSTANT = None\n'''      )

          __UpperCAmelCase     :			Union[str, Any]  							=      create_dummy_object('''function'''							,			'''\'torch\''''      )
          self.assertEqual(
              snake_case							,			'''\ndef function(*args, **kwargs):\n    requires_backends(function, \'torch\')\n'''      )

          __UpperCAmelCase     :			Optional[int]  							=      '''
class FakeClass(metaclass=DummyObject):
    _backends = \'torch\'

    def __init__(self, *args, **kwargs):
        requires_backends(self, \'torch\')

    @classmethod
    def from_config(cls, *args, **kwargs):
        requires_backends(cls, \'torch\')

    @classmethod
    def from_pretrained(cls, *args, **kwargs):
        requires_backends(cls, \'torch\')
'''
          __UpperCAmelCase     :			Optional[Any]  							=      create_dummy_object('''FakeClass'''							,			'''\'torch\''''      )
          self.assertEqual(snake_case							,			snake_case      )






     def 			lowerCamelCase__			(    self					:		int      )						->							List[Any]:
          __UpperCAmelCase     :			List[str]  							=      '''# This file is autogenerated by the command `make fix-copies`, do not edit.
from ..utils import DummyObject, requires_backends


CONSTANT = None


def function(*args, **kwargs):
    requires_backends(function, ["torch"])


class FakeClass(metaclass=DummyObject):
    _backends = ["torch"]

    def __init__(self, *args, **kwargs):
        requires_backends(self, ["torch"])

    @classmethod
    def from_config(cls, *args, **kwargs):
        requires_backends(cls, ["torch"])

    @classmethod
    def from_pretrained(cls, *args, **kwargs):
        requires_backends(cls, ["torch"])
'''
          __UpperCAmelCase     :			Optional[int]  							=      create_dummy_files({'''torch''': ['''CONSTANT''', '''function''', '''FakeClass''']}      )
          self.assertEqual(dummy_files['''torch''']							,			snake_case      )