






from typing import List, Optional, Union

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


UpperCamelCase								=		logging.get_logger(__name__)

UpperCamelCase								=		{
    "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 				lowerCAmelCase_	(		__snake_case			):
				_UpperCamelCase					:       Dict							       = "informer"
				_UpperCamelCase					:       Any							       = {
				    "hidden_size": "d_model",
				    "num_attention_heads": "encoder_attention_heads",
				    "num_hidden_layers": "encoder_layers",
				}


				def __init__(					self ,						_lowerCAmelCase = None ,						_lowerCAmelCase = None ,						_lowerCAmelCase = "student_t" ,						_lowerCAmelCase = "nll" ,						_lowerCAmelCase = 1 ,						_lowerCAmelCase = None ,						_lowerCAmelCase = "mean" ,						_lowerCAmelCase = 0 ,						_lowerCAmelCase = 0 ,						_lowerCAmelCase = 0 ,						_lowerCAmelCase = 0 ,						_lowerCAmelCase = None ,						_lowerCAmelCase = None ,						_lowerCAmelCase = 6_4 ,						_lowerCAmelCase = 3_2 ,						_lowerCAmelCase = 3_2 ,						_lowerCAmelCase = 2 ,						_lowerCAmelCase = 2 ,						_lowerCAmelCase = 2 ,						_lowerCAmelCase = 2 ,						_lowerCAmelCase = True ,						_lowerCAmelCase = "gelu" ,						_lowerCAmelCase = 0.05 ,						_lowerCAmelCase = 0.1 ,						_lowerCAmelCase = 0.1 ,						_lowerCAmelCase = 0.1 ,						_lowerCAmelCase = 0.1 ,						_lowerCAmelCase = 1_0_0 ,						_lowerCAmelCase = 0.02 ,						_lowerCAmelCase=True ,						_lowerCAmelCase = "prob" ,						_lowerCAmelCase = 5 ,						_lowerCAmelCase = True ,						**_lowerCAmelCase ,						):
											# time series specific configuration
											_lowercase							:   int 							=   prediction_length
											_lowercase							:   str 							=   context_length or prediction_length
											_lowercase							:   List[str] 							=   distribution_output
											_lowercase							:   List[Any] 							=   loss
											_lowercase							:   Optional[int] 							=   input_size
											_lowercase							:   int 							=   num_time_features
											_lowercase							:   int 							=   lags_sequence if lags_sequence is not None else [1, 2, 3, 4, 5, 6, 7]
											_lowercase							:   Tuple 							=   scaling
											_lowercase							:   Any 							=   num_dynamic_real_features
											_lowercase							:   Union[str, Any] 							=   num_static_real_features
											_lowercase							:   int 							=   num_static_categorical_features

											# set cardinality
											if cardinality and num_static_categorical_features > 0:
																		if len(_lowerCAmelCase      ) != num_static_categorical_features:
																									raise ValueError(
																									    'The cardinality should be a list of the same length as `num_static_categorical_features`'      )
																		_lowercase							:   Tuple 							=   cardinality
											else:
																		_lowercase							:   Tuple 							=   [0]

											# set embedding_dimension
											if embedding_dimension and num_static_categorical_features > 0:
																		if len(_lowerCAmelCase      ) != num_static_categorical_features:
																									raise ValueError(
																									    'The embedding dimension should be a list of the same length as `num_static_categorical_features`'      )
																		_lowercase							:   List[str] 							=   embedding_dimension
											else:
																		_lowercase							:   Tuple 							=   [min(5_0 ,						(cat + 1) // 2      ) for cat in self.cardinality]

											_lowercase							:   List[str] 							=   num_parallel_samples

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

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

											_lowercase							:   int 							=   activation_function
											_lowercase							:   Any 							=   init_std

											_lowercase							:   int 							=   use_cache

											# Informer
											_lowercase							:   Optional[int] 							=   attention_type
											_lowercase							:   Union[str, Any] 							=   sampling_factor
											_lowercase							:   Optional[int] 							=   distil

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


				@property
				def 						__a					(					self      ):
											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 copy
from typing import Dict, Optional

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto import CONFIG_MAPPING
from ..detr import DetrConfig
from ..swin import SwinConfig


__snake_case       =       {
    """facebook/maskformer-swin-base-ade""": (
        """https://huggingface.co/facebook/maskformer-swin-base-ade/blob/main/config.json"""
    )
    # See all MaskFormer models at https://huggingface.co/models?filter=maskformer
}

__snake_case       =       logging.get_logger(__name__)







class _lowerCAmelCase							( snake_case_      ):
   __UpperCAmelCase					:			Any				    =    '''maskformer'''
   __UpperCAmelCase					:			List[str]				    =    {'''hidden_size''': '''mask_feature_size'''}
   __UpperCAmelCase					:			Optional[Any]				    =    ['''resnet''', '''swin''']
   __UpperCAmelCase					:			str				    =    ['''detr''']







   def __init__(      self		,      UpperCamelCase__ = 256		,      UpperCamelCase__ = 256		,      UpperCamelCase__ = 0.1		,      UpperCamelCase__ = False		,      UpperCamelCase__ = None		,      UpperCamelCase__ = None		,      UpperCamelCase__ = 0.02		,      UpperCamelCase__ = 1.0		,      UpperCamelCase__ = 1.0		,      UpperCamelCase__ = 1.0		,      UpperCamelCase__ = 20.0		,      UpperCamelCase__ = None		,      **UpperCamelCase__		,      )      ->						Optional[int]:

       '''simple docstring'''




       if backbone_config is None:
           # fall back to https://huggingface.co/microsoft/swin-base-patch4-window12-384-in22k
           snake_case       : Tuple    =       SwinConfig(
               image_size=384		,      in_channels=3		,      patch_size=4		,      embed_dim=128		,      depths=[2, 2, 18, 2]		,      num_heads=[4, 8, 16, 32]		,      window_size=12		,      drop_path_rate=0.3		,      out_features=["stage1", "stage2", "stage3", "stage4"]		,      )

       if isinstance(UpperCamelCase__		,      UpperCamelCase__		):
           snake_case       : Optional[Any]    =       backbone_config.pop("model_type"		)
           snake_case       : List[str]    =       CONFIG_MAPPING[backbone_model_type]
           snake_case       : str    =       config_class.from_dict(UpperCamelCase__		)

       # verify that the backbone is supported
       if backbone_config.model_type not in self.backbones_supported:
           logger.warning_once(
               F'Backbone {backbone_config.model_type} is not a supported model and may not be compatible with MaskFormer. '
               F'Supported model types: {",".join(self.backbones_supported		)}'		)

       if decoder_config is None:
           # fall back to https://huggingface.co/facebook/detr-resnet-50
           snake_case       : Optional[int]    =       DetrConfig()
       else:
           # verify that the decoder is supported
           snake_case       : Optional[Any]    =       (
               decoder_config.pop("model_type"		) if isinstance(UpperCamelCase__		,      UpperCamelCase__		) else decoder_config.model_type
           )
           if decoder_type not in self.decoders_supported:
               raise ValueError(
                   F'Transformer Decoder {decoder_type} not supported, please use one of'
                   F' {",".join(self.decoders_supported		)}'		)
           if isinstance(UpperCamelCase__		,      UpperCamelCase__		):
               snake_case       : Dict    =       CONFIG_MAPPING[decoder_type]
               snake_case       : List[Any]    =       config_class.from_dict(UpperCamelCase__		)

       snake_case       : Optional[int]    =       backbone_config
       snake_case       : Optional[Any]    =       decoder_config
       # main feature dimension for the model
       snake_case       : List[str]    =       fpn_feature_size
       snake_case       : Tuple    =       mask_feature_size
       # initializer
       snake_case       : str    =       init_std
       snake_case       : str    =       init_xavier_std
       # Hungarian matcher && loss
       snake_case       : List[Any]    =       cross_entropy_weight
       snake_case       : int    =       dice_weight
       snake_case       : str    =       mask_weight
       snake_case       : Any    =       use_auxiliary_loss
       snake_case       : Any    =       no_object_weight
       snake_case       : List[Any]    =       output_auxiliary_logits

       snake_case       : Optional[int]    =       self.decoder_config.encoder_attention_heads
       snake_case       : Tuple    =       self.decoder_config.num_hidden_layers
       super().__init__(**UpperCamelCase__		)







   @classmethod
   def 					lowerCamelCase						(      cls		,      UpperCamelCase__		,      UpperCamelCase__		,      **UpperCamelCase__		)      ->						Optional[int]:

       '''simple docstring'''




       return cls(
           backbone_config=UpperCamelCase__		,      decoder_config=UpperCamelCase__		,      **UpperCamelCase__		,      )







   def 					lowerCamelCase						(      self		)      ->						Dict[str, any]:

       '''simple docstring'''




       snake_case       : int    =       copy.deepcopy(self.__dict__		)
       snake_case       : List[str]    =       self.backbone_config.to_dict()
       snake_case       : Union[str, Any]    =       self.decoder_config.to_dict()
       snake_case       : Optional[int]    =       self.__class__.model_type
       return output





