


import copy
from typing import Dict, List, Optional

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto import CONFIG_MAPPING


a       	=  {
    'facebook/mask2former-swin-small-coco-instance': (
        'https://huggingface.co/facebook/mask2former-swin-small-coco-instance/blob/main/config.json'
    )
    # See all Mask2Former models at https://huggingface.co/models?filter=mask2former
}

a       	=  logging.get_logger(__name__)







class 							UpperCamelCase__ (						__magic_name__ ):
					__SCREAMING_SNAKE_CASE							:	Union[str, Any]            = "mask2former"
					__SCREAMING_SNAKE_CASE							:	Optional[Any]            = ["swin"]
					__SCREAMING_SNAKE_CASE							:	str            = {"hidden_size": "hidden_dim"}

					def __init__(  self							: Union[str, Any]				,       UpperCamelCase__							: Dict = None				,       UpperCamelCase__							: Dict = 256				,       UpperCamelCase__							: Union[str, Any] = 256				,       UpperCamelCase__							: Any = 256				,       UpperCamelCase__							: Dict = 1_024				,       UpperCamelCase__							: List[Any] = "relu"				,       UpperCamelCase__							: Optional[Any] = 6				,       UpperCamelCase__							: int = 10				,       UpperCamelCase__							: str = 8				,       UpperCamelCase__							: Optional[Any] = 0.0				,       UpperCamelCase__							: Tuple = 2_048				,       UpperCamelCase__							: List[Any] = False				,       UpperCamelCase__							: List[str] = False				,       UpperCamelCase__							: List[str] = 4				,       UpperCamelCase__							: int = 255				,       UpperCamelCase__							: int = 100				,       UpperCamelCase__							: str = 0.1				,       UpperCamelCase__							: List[Any] = 2.0				,       UpperCamelCase__							: Tuple = 5.0				,       UpperCamelCase__							: List[str] = 5.0				,       UpperCamelCase__							: Any = 12_544				,       UpperCamelCase__							: Optional[Any] = 3.0				,       UpperCamelCase__							: Optional[Any] = 0.75				,       UpperCamelCase__							: List[str] = 0.02				,       UpperCamelCase__							: Union[str, Any] = 1.0				,       UpperCamelCase__							: List[str] = True				,       UpperCamelCase__							: str = [4, 8, 16, 32]				,       UpperCamelCase__							: List[Any] = None				,       **UpperCamelCase__							: Optional[Any]				,       ):






										'''simple docstring'''






										if backbone_config is None:
															logger.info("""`backbone_config` is `None`. Initializing the config with the default `Swin` backbone."""							)
															lowercase_					=      CONFIG_MAPPING["""swin"""](
															    image_size=224				,       in_channels=3				,       patch_size=4				,       embed_dim=96				,       depths=[2, 2, 18, 2]				,       num_heads=[3, 6, 12, 24]				,       window_size=7				,       drop_path_rate=0.3				,       use_absolute_embeddings=_lowerCAmelCase				,       out_features=["""stage1""", """stage2""", """stage3""", """stage4"""]				,       )

										if isinstance(_lowerCAmelCase				,       _lowerCAmelCase							):
															lowercase_					=      backbone_config.pop("""model_type"""							)
															lowercase_					=      CONFIG_MAPPING[backbone_model_type]
															lowercase_					=      config_class.from_dict(_lowerCAmelCase							)

										# 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 Mask2Former. '''
															    F'''Supported model types: {",".join(self.backbones_supported							)}'''							)

										lowercase_					=      backbone_config
										lowercase_					=      feature_size
										lowercase_					=      mask_feature_size
										lowercase_					=      hidden_dim
										lowercase_					=      encoder_feedforward_dim
										lowercase_					=      activation_function
										lowercase_					=      encoder_layers
										lowercase_					=      decoder_layers
										lowercase_					=      num_attention_heads
										lowercase_					=      dropout
										lowercase_					=      dim_feedforward
										lowercase_					=      pre_norm
										lowercase_					=      enforce_input_projection
										lowercase_					=      common_stride
										lowercase_					=      ignore_value
										lowercase_					=      num_queries
										lowercase_					=      no_object_weight
										lowercase_					=      class_weight
										lowercase_					=      mask_weight
										lowercase_					=      dice_weight
										lowercase_					=      train_num_points
										lowercase_					=      oversample_ratio
										lowercase_					=      importance_sample_ratio
										lowercase_					=      init_std
										lowercase_					=      init_xavier_std
										lowercase_					=      use_auxiliary_loss
										lowercase_					=      feature_strides
										lowercase_					=      output_auxiliary_logits
										lowercase_					=      decoder_layers

										super().__init__(**_lowerCAmelCase							)

					@classmethod
					def 	UpperCAmelCase__							(  cls							: Optional[Any]				,       UpperCamelCase__							: Dict				,       **UpperCamelCase__							: Tuple							):






										'''simple docstring'''






										return cls(
										    backbone_config=_lowerCAmelCase				,       **_lowerCAmelCase				,       )







					def 	UpperCAmelCase__							(  self							: str							):






										'''simple docstring'''






										lowercase_					=      copy.deepcopy(self.__dict__							)
										lowercase_					=      self.backbone_config.to_dict()
										lowercase_					=      self.__class__.model_type
										return output









'''simple docstring'''


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


_SCREAMING_SNAKE_CASE									=				logging.get_logger(__name__)

_SCREAMING_SNAKE_CASE									=				{
    "tiiuae/falcon-40b": "https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json",
    "tiiuae/falcon-7b": "https://huggingface.co/tiiuae/falcon-7b/resolve/main/config.json",
}

class  lowerCAmelCase_		(		__magic_name__		):
 __lowerCamelCase    :				Any								=       "falcon"
 __lowerCamelCase    :				List[str]								=       ["past_key_values"]




 def __init__(						self      ,  _lowerCAmelCase=65024      ,  _lowerCAmelCase=4544      ,  _lowerCAmelCase=32      ,  _lowerCAmelCase=71      ,  _lowerCAmelCase=1E-5      ,  _lowerCAmelCase=0.02      ,  _lowerCAmelCase=True      ,  _lowerCAmelCase=0.0      ,  _lowerCAmelCase=0.0      ,  _lowerCAmelCase=None      ,  _lowerCAmelCase=False      ,  _lowerCAmelCase=False      ,  _lowerCAmelCase=True      ,  _lowerCAmelCase=True      ,  _lowerCAmelCase=False      ,  _lowerCAmelCase=11      ,  _lowerCAmelCase=11      ,  **_lowerCAmelCase      ,  )     ->				Union[str, Any]:
     _lowerCAmelCase						      =   vocab_size
     # Backward compatibility with n_embed kwarg
     _lowerCAmelCase						      =   kwargs.pop("n_embed"      ,  _lowerCAmelCase		)
     _lowerCAmelCase						      =   hidden_size if n_embed is None else n_embed
     _lowerCAmelCase						      =   num_hidden_layers
     _lowerCAmelCase						      =   num_attention_heads
     _lowerCAmelCase						      =   layer_norm_epsilon
     _lowerCAmelCase						      =   initializer_range
     _lowerCAmelCase						      =   use_cache
     _lowerCAmelCase						      =   hidden_dropout
     _lowerCAmelCase						      =   attention_dropout

     _lowerCAmelCase						      =   bos_token_id
     _lowerCAmelCase						      =   eos_token_id
     _lowerCAmelCase						      =   num_attention_heads if num_kv_heads is None else num_kv_heads
     _lowerCAmelCase						      =   alibi
     _lowerCAmelCase						      =   new_decoder_architecture
     _lowerCAmelCase						      =   multi_query  # Ignored when new_decoder_architecture is True
     _lowerCAmelCase						      =   parallel_attn
     _lowerCAmelCase						      =   bias

     super().__init__(bos_token_id=_lowerCAmelCase      ,  eos_token_id=_lowerCAmelCase      ,  **_lowerCAmelCase		)




 @property
 def 				_snake_case (						self		)     ->				Optional[Any]:
     return self.hidden_size // self.num_attention_heads





 @property
 def 				_snake_case (						self		)     ->				Optional[Any]:
     return not self.alibi


