'''simple docstring'''


import collections
import inspect
import unittest
from typing import Dict, List, Tuple

from transformers import MaskFormerSwinConfig
from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device
from transformers.utils import is_torch_available

from ...test_backbone_common import BackboneTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
 import torch
 from torch import nn

 from transformers import MaskFormerSwinBackbone
 from transformers.models.maskformer import MaskFormerSwinModel






class 					__SCREAMING_SNAKE_CASE						:







  '''simple docstring'''






  def __init__(			self				,		snake_case_				,		snake_case_=1_3				,		snake_case_=3_2				,		snake_case_=2				,		snake_case_=3				,		snake_case_=1_6				,		snake_case_=[1, 2, 1]				,		snake_case_=[2, 2, 4]				,		snake_case_=2				,		snake_case_=2.0				,		snake_case_=True				,		snake_case_=0.0				,		snake_case_=0.0				,		snake_case_=0.1				,		snake_case_="gelu"				,		snake_case_=False				,		snake_case_=True				,		snake_case_=0.02				,		snake_case_=1E-5				,		snake_case_=True				,		snake_case_=None				,		snake_case_=True				,		snake_case_=1_0				,		snake_case_=8				,		snake_case_=["stage1", "stage2", "stage3"]				,		snake_case_=[1, 2, 3]				,		):




       '''simple docstring'''

       UpperCAmelCase_							:       Optional[int]       =				parent
       UpperCAmelCase_							:       Any       =				batch_size
       UpperCAmelCase_							:       Optional[Any]       =				image_size
       UpperCAmelCase_							:       int       =				patch_size
       UpperCAmelCase_							:       str       =				num_channels
       UpperCAmelCase_							:       Optional[int]       =				embed_dim
       UpperCAmelCase_							:       Optional[Any]       =				depths
       UpperCAmelCase_							:       Union[str, Any]       =				num_heads
       UpperCAmelCase_							:       List[Any]       =				window_size
       UpperCAmelCase_							:       str       =				mlp_ratio
       UpperCAmelCase_							:       Union[str, Any]       =				qkv_bias
       UpperCAmelCase_							:       Optional[Any]       =				hidden_dropout_prob
       UpperCAmelCase_							:       int       =				attention_probs_dropout_prob
       UpperCAmelCase_							:       List[str]       =				drop_path_rate
       UpperCAmelCase_							:       List[str]       =				hidden_act
       UpperCAmelCase_							:       Union[str, Any]       =				use_absolute_embeddings
       UpperCAmelCase_							:       List[str]       =				patch_norm
       UpperCAmelCase_							:       Dict       =				layer_norm_eps
       UpperCAmelCase_							:       Union[str, Any]       =				initializer_range
       UpperCAmelCase_							:       Union[str, Any]       =				is_training
       UpperCAmelCase_							:       int       =				scope
       UpperCAmelCase_							:       Optional[int]       =				use_labels
       UpperCAmelCase_							:       Tuple       =				type_sequence_label_size
       UpperCAmelCase_							:       Tuple       =				encoder_stride
       UpperCAmelCase_							:       List[Any]       =				out_features
       UpperCAmelCase_							:       Union[str, Any]       =				out_indices


  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       UpperCAmelCase_							:       Optional[Any]       =				floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]						)

       UpperCAmelCase_							:       Dict       =				None
       if self.use_labels:
            UpperCAmelCase_							:       str       =				ids_tensor([self.batch_size]				,		self.type_sequence_label_size						)

       UpperCAmelCase_							:       str       =				self.get_config()

       return config, pixel_values, labels


  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       return MaskFormerSwinConfig(
           image_size=self.image_size				,		patch_size=self.patch_size				,		num_channels=self.num_channels				,		embed_dim=self.embed_dim				,		depths=self.depths				,		num_heads=self.num_heads				,		window_size=self.window_size				,		mlp_ratio=self.mlp_ratio				,		qkv_bias=self.qkv_bias				,		hidden_dropout_prob=self.hidden_dropout_prob				,		attention_probs_dropout_prob=self.attention_probs_dropout_prob				,		drop_path_rate=self.drop_path_rate				,		hidden_act=self.hidden_act				,		use_absolute_embeddings=self.use_absolute_embeddings				,		path_norm=self.patch_norm				,		layer_norm_eps=self.layer_norm_eps				,		initializer_range=self.initializer_range				,		encoder_stride=self.encoder_stride				,		out_features=self.out_features				,		out_indices=self.out_indices				,		)


  def _UpperCamelCase					(			self				,		snake_case_				,		snake_case_				,		snake_case_						):




       '''simple docstring'''

       UpperCAmelCase_							:       Dict       =				MaskFormerSwinModel(config=snake_case_						)
       model.to(snake_case_						)
       model.eval()
       UpperCAmelCase_							:       Optional[int]       =				model(snake_case_						)

       UpperCAmelCase_							:       List[Any]       =				((config.image_size // config.patch_size) ** 2) // (4 ** (len(config.depths						) - 1))
       UpperCAmelCase_							:       Dict       =				int(config.embed_dim * 2 ** (len(config.depths						) - 1)						)

       self.parent.assertEqual(result.last_hidden_state.shape				,		(self.batch_size, expected_seq_len, expected_dim)						)


  def _UpperCamelCase					(			self				,		snake_case_				,		snake_case_				,		snake_case_						):




       '''simple docstring'''

       UpperCAmelCase_							:       Any       =				MaskFormerSwinBackbone(config=snake_case_						)
       model.to(snake_case_						)
       model.eval()
       UpperCAmelCase_							:       Union[str, Any]       =				model(snake_case_						)

       # verify feature maps
       self.parent.assertEqual(len(result.feature_maps						)				,		len(config.out_features						)						)
       self.parent.assertListEqual(list(result.feature_maps[0].shape						)				,		[1_3, 1_6, 1_6, 1_6]						)

       # verify channels
       self.parent.assertEqual(len(model.channels						)				,		len(config.out_features						)						)
       self.parent.assertListEqual(model.channels				,		[1_6, 3_2, 6_4]						)

       # verify ValueError
       with self.parent.assertRaises(snake_case_						):
            UpperCAmelCase_							:       str       =				['stem']
            UpperCAmelCase_							:       Tuple       =				MaskFormerSwinBackbone(config=snake_case_						)






  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       UpperCAmelCase_							:       int       =				self.prepare_config_and_inputs()
       UpperCAmelCase_       ,      UpperCAmelCase_       ,      UpperCAmelCase_							:       Optional[int]       =				config_and_inputs
       UpperCAmelCase_							:       Union[str, Any]       =				{'pixel_values': pixel_values}
       return config, inputs_dict







@require_torch
class 					__SCREAMING_SNAKE_CASE						(	lowerCamelCase_						,     lowerCamelCase_						,     unittest.TestCase	):







  '''simple docstring'''






  lowerCamelCase_		:Any						   =		(
      (
          MaskFormerSwinModel,
          MaskFormerSwinBackbone,
      )
      if is_torch_available()
      else ()
  )
  lowerCamelCase_		:Optional[int]						   =		{'''feature-extraction''': MaskFormerSwinModel} if is_torch_available() else {}
  lowerCamelCase_		:Optional[int]						   =		False
  lowerCamelCase_		:Optional[int]						   =		False
  lowerCamelCase_		:List[str]						   =		False
  lowerCamelCase_		:Dict						   =		False
  lowerCamelCase_		:str						   =		False


  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       UpperCAmelCase_							:       Optional[int]       =				MaskFormerSwinModelTester(self						)
       UpperCAmelCase_							:       Union[str, Any]       =				ConfigTester(self				,		config_class=snake_case_				,		embed_dim=3_7						)


  @require_torch_multi_gpu
  @unittest.skip(
      reason=(
          '`MaskFormerSwinModel` outputs `hidden_states_spatial_dimensions` which doesn\'t work well with'
          ' `nn.DataParallel`'
      )						)
  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       pass


  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       self.create_and_test_config_common_properties()
       self.config_tester.create_and_test_config_to_json_string()
       self.config_tester.create_and_test_config_to_json_file()
       self.config_tester.create_and_test_config_from_and_save_pretrained()
       self.config_tester.create_and_test_config_with_num_labels()
       self.config_tester.check_config_can_be_init_without_params()
       self.config_tester.check_config_arguments_init()


  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       return


  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       UpperCAmelCase_							:       Any       =				self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_model(*snake_case_						)


  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       UpperCAmelCase_							:       Optional[int]       =				self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_backbone(*snake_case_						)


  @unittest.skip('Swin does not use inputs_embeds'						)
  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       pass


  @unittest.skip('Swin does not support feedforward chunking'						)
  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       pass


  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       UpperCAmelCase_       ,      UpperCAmelCase_							:       Optional[Any]       =				self.model_tester.prepare_config_and_inputs_for_common()

       for model_class in self.all_model_classes:
            UpperCAmelCase_							:       List[Any]       =				model_class(snake_case_						)
            self.assertIsInstance(model.get_input_embeddings()				,		(nn.Module)						)
            UpperCAmelCase_							:       Any       =				model.get_output_embeddings()
            self.assertTrue(x is None or isinstance(snake_case_				,		nn.Linear						)						)


  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       UpperCAmelCase_       ,      UpperCAmelCase_							:       Any       =				self.model_tester.prepare_config_and_inputs_for_common()

       for model_class in self.all_model_classes:
            UpperCAmelCase_							:       int       =				model_class(snake_case_						)
            UpperCAmelCase_							:       Union[str, Any]       =				inspect.signature(model.forward						)
            # signature.parameters is an OrderedDict => so arg_names order is deterministic
            UpperCAmelCase_							:       Union[str, Any]       =				[*signature.parameters.keys()]

            UpperCAmelCase_							:       Any       =				['pixel_values']
            self.assertListEqual(arg_names[:1]				,		snake_case_						)


  @unittest.skip(reason='MaskFormerSwin is only used as backbone and doesn\'t support output_attentions'						)
  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       pass


  @unittest.skip(reason='MaskFormerSwin is only used as an internal backbone'						)
  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       pass


  def _UpperCamelCase					(			self				,		snake_case_				,		snake_case_				,		snake_case_				,		snake_case_						):




       '''simple docstring'''

       UpperCAmelCase_							:       str       =				model_class(snake_case_						)
       model.to(snake_case_						)
       model.eval()

       with torch.no_grad():
            UpperCAmelCase_							:       Tuple       =				model(**self._prepare_for_class(snake_case_				,		snake_case_						)						)

       UpperCAmelCase_							:       Dict       =				outputs.hidden_states

       UpperCAmelCase_							:       str       =				getattr(
           self.model_tester				,		'expected_num_hidden_layers'				,		len(self.model_tester.depths						) + 1						)
       self.assertEqual(len(snake_case_						)				,		snake_case_						)

       # Swin has a different seq_length
       UpperCAmelCase_							:       Dict       =				(
           config.patch_size
           if isinstance(config.patch_size				,		collections.abc.Iterable						)
           else (config.patch_size, config.patch_size)
       )

       UpperCAmelCase_							:       Union[str, Any]       =				(image_size[1] // patch_size[1]) * (image_size[0] // patch_size[0])

       self.assertListEqual(
           list(hidden_states[0].shape[-2:]						)				,		[num_patches, self.model_tester.embed_dim]				,		)


  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       UpperCAmelCase_       ,      UpperCAmelCase_							:       Dict       =				self.model_tester.prepare_config_and_inputs_for_common()

       UpperCAmelCase_							:       str       =				(
           self.model_tester.image_size
           if isinstance(self.model_tester.image_size				,		collections.abc.Iterable						)
           else (self.model_tester.image_size, self.model_tester.image_size)
       )

       for model_class in self.all_model_classes:
            UpperCAmelCase_							:       Union[str, Any]       =				True
            self.check_hidden_states_output(snake_case_				,		snake_case_				,		snake_case_				,		snake_case_						)

            # check that output_hidden_states also work using config
            del inputs_dict["output_hidden_states"]
            UpperCAmelCase_							:       List[Any]       =				True

            self.check_hidden_states_output(snake_case_				,		snake_case_				,		snake_case_				,		snake_case_						)


  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       UpperCAmelCase_       ,      UpperCAmelCase_							:       Optional[Any]       =				self.model_tester.prepare_config_and_inputs_for_common()
       UpperCAmelCase_							:       str       =				3

       UpperCAmelCase_							:       str       =				(
           self.model_tester.image_size
           if isinstance(self.model_tester.image_size				,		collections.abc.Iterable						)
           else (self.model_tester.image_size, self.model_tester.image_size)
       )
       UpperCAmelCase_							:       Dict       =				(
           config.patch_size
           if isinstance(config.patch_size				,		collections.abc.Iterable						)
           else (config.patch_size, config.patch_size)
       )

       UpperCAmelCase_							:       Dict       =				image_size[0] + patch_size[0] - (image_size[0] % patch_size[0])
       UpperCAmelCase_							:       Dict       =				image_size[1] + patch_size[1] - (image_size[1] % patch_size[1])

       for model_class in self.all_model_classes:
            UpperCAmelCase_							:       Optional[int]       =				True
            self.check_hidden_states_output(snake_case_				,		snake_case_				,		snake_case_				,		(padded_height, padded_width)						)

            # check that output_hidden_states also work using config
            del inputs_dict["output_hidden_states"]
            UpperCAmelCase_							:       Tuple       =				True
            self.check_hidden_states_output(snake_case_				,		snake_case_				,		snake_case_				,		(padded_height, padded_width)						)


  @unittest.skip(reason='MaskFormerSwin doesn\'t have pretrained checkpoints'						)
  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       pass


  @unittest.skip(reason='This will be fixed once MaskFormerSwin is replaced by native Swin'						)
  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       pass


  @unittest.skip(reason='This will be fixed once MaskFormerSwin is replaced by native Swin'						)
  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       pass






  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       UpperCAmelCase_       ,      UpperCAmelCase_							:       Tuple       =				self.model_tester.prepare_config_and_inputs_for_common()

       def set_nan_tensor_to_zero(snake_case_						):
            UpperCAmelCase_							:       Union[str, Any]       =				0
            return t

       def check_equivalence(snake_case_				,		snake_case_				,		snake_case_				,		snake_case_={}						):
            with torch.no_grad():
                 UpperCAmelCase_							:       Any       =				model(**snake_case_				,		return_dict=snake_case_				,		**snake_case_						)
                 UpperCAmelCase_							:       List[str]       =				model(**snake_case_				,		return_dict=snake_case_				,		**snake_case_						).to_tuple()

                 def recursive_check(snake_case_				,		snake_case_						):
                      if isinstance(snake_case_				,		(List, Tuple)						):
                           for tuple_iterable_value, dict_iterable_value in zip(snake_case_				,		snake_case_						):
                                recursive_check(snake_case_				,		snake_case_						)
                      elif isinstance(snake_case_				,		snake_case_						):
                           for tuple_iterable_value, dict_iterable_value in zip(
                               tuple_object.values()				,		dict_object.values()						):
                                recursive_check(snake_case_				,		snake_case_						)
                      elif tuple_object is None:
                           return
                      else:
                           self.assertTrue(
                               torch.allclose(
                                   set_nan_tensor_to_zero(snake_case_						)				,		set_nan_tensor_to_zero(snake_case_						)				,		atol=1E-5						)				,		msg=(
                                   'Tuple and dict output are not equal. Difference:'
                                   F''' {torch.max(torch.abs(tuple_object - dict_object						)						)}. Tuple has `nan`:'''
                                   F''' {torch.isnan(snake_case_						).any()} and `inf`: {torch.isinf(snake_case_						)}. Dict has'''
                                   F''' `nan`: {torch.isnan(snake_case_						).any()} and `inf`: {torch.isinf(snake_case_						)}.'''
                               )				,		)

                 recursive_check(snake_case_				,		snake_case_						)

       for model_class in self.all_model_classes:
            UpperCAmelCase_							:       List[str]       =				model_class(snake_case_						)
            model.to(snake_case_						)
            model.eval()

            UpperCAmelCase_							:       int       =				self._prepare_for_class(snake_case_				,		snake_case_						)
            UpperCAmelCase_							:       str       =				self._prepare_for_class(snake_case_				,		snake_case_						)
            check_equivalence(snake_case_				,		snake_case_				,		snake_case_						)

            UpperCAmelCase_							:       List[str]       =				self._prepare_for_class(snake_case_				,		snake_case_				,		return_labels=snake_case_						)
            UpperCAmelCase_							:       Optional[int]       =				self._prepare_for_class(snake_case_				,		snake_case_				,		return_labels=snake_case_						)
            check_equivalence(snake_case_				,		snake_case_				,		snake_case_						)

            UpperCAmelCase_							:       Dict       =				self._prepare_for_class(snake_case_				,		snake_case_						)
            UpperCAmelCase_							:       Union[str, Any]       =				self._prepare_for_class(snake_case_				,		snake_case_						)
            check_equivalence(snake_case_				,		snake_case_				,		snake_case_				,		{'output_hidden_states': True}						)

            UpperCAmelCase_							:       str       =				self._prepare_for_class(snake_case_				,		snake_case_				,		return_labels=snake_case_						)
            UpperCAmelCase_							:       List[str]       =				self._prepare_for_class(snake_case_				,		snake_case_				,		return_labels=snake_case_						)
            check_equivalence(snake_case_				,		snake_case_				,		snake_case_				,		{'output_hidden_states': True}						)







@require_torch
class 					__SCREAMING_SNAKE_CASE						(	unittest.TestCase						,     lowerCamelCase_	):







  '''simple docstring'''






  lowerCamelCase_		:Union[str, Any]						   =		(MaskFormerSwinBackbone,) if is_torch_available() else ()
  lowerCamelCase_		:List[Any]						   =		MaskFormerSwinConfig


  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       UpperCAmelCase_							:       List[str]       =				MaskFormerSwinModelTester(self						)






  def _UpperCamelCase					(			self						):




       '''simple docstring'''

       UpperCAmelCase_       ,      UpperCAmelCase_							:       List[str]       =				self.model_tester.prepare_config_and_inputs_for_common()
       UpperCAmelCase_							:       Optional[int]       =				inputs_dict['pixel_values'].shape[0]

       for backbone_class in self.all_model_classes:
            UpperCAmelCase_							:       Optional[Any]       =				backbone_class(snake_case_						)
            backbone.to(snake_case_						)
            backbone.eval()

            UpperCAmelCase_							:       Any       =				backbone(**snake_case_						)

            # Test default outputs and verify feature maps
            self.assertIsInstance(outputs.feature_maps				,		snake_case_						)
            self.assertTrue(len(outputs.feature_maps						) == len(backbone.channels						)						)
            for feature_map, n_channels in zip(outputs.feature_maps				,		backbone.channels						):
                 self.assertTrue(feature_map.shape[:2]				,		(batch_size, n_channels)						)
            self.assertIsNone(outputs.hidden_states						)
            self.assertIsNone(outputs.attentions						)

            # Test output_hidden_states=True
            UpperCAmelCase_							:       List[str]       =				backbone(**snake_case_				,		output_hidden_states=snake_case_						)
            self.assertIsNotNone(outputs.hidden_states						)
            self.assertTrue(len(outputs.hidden_states						)				,		len(backbone.stage_names						)						)
            # We skip the stem layer
            for hidden_states, n_channels in zip(outputs.hidden_states[1:]				,		backbone.channels						):
                 for hidden_state in hidden_states:
                      # Hidden states are in the format (batch_size, (height * width), n_channels)
                      UpperCAmelCase_       ,      UpperCAmelCase_       ,      UpperCAmelCase_							:       Tuple       =				hidden_state.shape
                      self.assertTrue((h_batch_size, h_n_channels)				,		(batch_size, n_channels)						)

            # Test output_attentions=True
            if self.has_attentions:
                 UpperCAmelCase_							:       Union[str, Any]       =				backbone(**snake_case_				,		output_attentions=snake_case_						)
                 self.assertIsNotNone(outputs.attentions						)







'''simple docstring'''


from typing import List, Optional

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


snake_case__					:      List[Any]				      =  logging.get_logger(__name__)

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






class 					__SCREAMING_SNAKE_CASE						(	lowerCamelCase_	):







  '''simple docstring'''






  lowerCamelCase_		:List[str]						   =		'''autoformer'''
  lowerCamelCase_		:Optional[Any]						   =		{
      '''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_ = [1, 2, 3, 4, 5, 6, 7]				,		snake_case_ = True				,		snake_case_ = 0				,		snake_case_ = 0				,		snake_case_ = 0				,		snake_case_ = 0				,		snake_case_ = None				,		snake_case_ = None				,		snake_case_ = 6_4				,		snake_case_ = 2				,		snake_case_ = 2				,		snake_case_ = 2				,		snake_case_ = 2				,		snake_case_ = 3_2				,		snake_case_ = 3_2				,		snake_case_ = "gelu"				,		snake_case_ = 0.1				,		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_=True				,		snake_case_ = 1_0				,		snake_case_ = 2_5				,		snake_case_ = 3				,		**snake_case_				,		):




       '''simple docstring'''

       UpperCAmelCase_							:       List[Any]       =				prediction_length
       UpperCAmelCase_							:       List[str]       =				context_length if context_length is not None else prediction_length
       UpperCAmelCase_							:       Optional[int]       =				distribution_output
       UpperCAmelCase_							:       Optional[int]       =				loss
       UpperCAmelCase_							:       Union[str, Any]       =				input_size
       UpperCAmelCase_							:       int       =				num_time_features
       UpperCAmelCase_							:       List[str]       =				lags_sequence
       UpperCAmelCase_							:       Any       =				scaling
       UpperCAmelCase_							:       Any       =				num_dynamic_real_features
       UpperCAmelCase_							:       int       =				num_static_real_features
       UpperCAmelCase_							:       Optional[Any]       =				num_static_categorical_features
       if cardinality is not None 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_							:       List[Any]       =				cardinality
       else:
            UpperCAmelCase_							:       Optional[int]       =				[0]
       if embedding_dimension is not None 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[str]       =				embedding_dimension
       else:
            UpperCAmelCase_							:       List[Any]       =				[min(5_0				,		(cat + 1) // 2						) for cat in self.cardinality]
       UpperCAmelCase_							:       List[str]       =				num_parallel_samples

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

       UpperCAmelCase_							:       str       =				dropout
       UpperCAmelCase_							:       Optional[int]       =				attention_dropout
       UpperCAmelCase_							:       Tuple       =				activation_dropout
       UpperCAmelCase_							:       Any       =				encoder_layerdrop
       UpperCAmelCase_							:       Tuple       =				decoder_layerdrop

       UpperCAmelCase_							:       List[str]       =				activation_function
       UpperCAmelCase_							:       Tuple       =				init_std

       UpperCAmelCase_							:       Union[str, Any]       =				use_cache

       # Autoformer
       UpperCAmelCase_							:       Any       =				label_length
       UpperCAmelCase_							:       Union[str, Any]       =				moving_average
       UpperCAmelCase_							:       Tuple       =				autocorrelation_factor

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






  @property
  def _UpperCamelCase					(			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
       )






