





import copy

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


UpperCamelCase__           =			logging.get_logger(__name__)

UpperCamelCase__           =			{
    "ut/deta": "https://huggingface.co/ut/deta/resolve/main/config.json",
}

class 							__SCREAMING_SNAKE_CASE       (  _a							):
							snake_case  :   Union[str, Any]      =							"""deta"""
							snake_case  :   Any      =							{
							    """hidden_size""": """d_model""",
							    """num_attention_heads""": """encoder_attention_heads""",
							}






							def __init__(    self	,			__lowerCAmelCase=None	,			__lowerCAmelCase=900	,			__lowerCAmelCase=2048	,			__lowerCAmelCase=6	,			__lowerCAmelCase=2048	,			__lowerCAmelCase=8	,			__lowerCAmelCase=6	,			__lowerCAmelCase=1024	,			__lowerCAmelCase=8	,			__lowerCAmelCase=0.0	,			__lowerCAmelCase=True	,			__lowerCAmelCase="relu"	,			__lowerCAmelCase=256	,			__lowerCAmelCase=0.1	,			__lowerCAmelCase=0.0	,			__lowerCAmelCase=0.0	,			__lowerCAmelCase=0.02	,			__lowerCAmelCase=1.0	,			__lowerCAmelCase=True	,			__lowerCAmelCase=False	,			__lowerCAmelCase="sine"	,			__lowerCAmelCase=5	,			__lowerCAmelCase=4	,			__lowerCAmelCase=4	,			__lowerCAmelCase=True	,			__lowerCAmelCase=300	,			__lowerCAmelCase=True	,			__lowerCAmelCase=True	,			__lowerCAmelCase=1	,			__lowerCAmelCase=5	,			__lowerCAmelCase=2	,			__lowerCAmelCase=1	,			__lowerCAmelCase=1	,			__lowerCAmelCase=5	,			__lowerCAmelCase=2	,			__lowerCAmelCase=0.1	,			__lowerCAmelCase=0.25	,			**__lowerCAmelCase	,			):
														if backbone_config is None:
																					logger.info("""`backbone_config` is `None`. Initializing the config with the default `ResNet` backbone."""	)
																					UpperCamelCase__					  =      CONFIG_MAPPING["""resnet"""](out_features=["""stage2""", """stage3""", """stage4"""]	)
														else:
																					if isinstance(__lowerCAmelCase	,			__lowerCAmelCase	):
																												UpperCamelCase__					  =      backbone_config.pop("""model_type"""	)
																												UpperCamelCase__					  =      CONFIG_MAPPING[backbone_model_type]
																												UpperCamelCase__					  =      config_class.from_dict(__lowerCAmelCase	)

														UpperCamelCase__					  =      backbone_config
														UpperCamelCase__					  =      num_queries
														UpperCamelCase__					  =      max_position_embeddings
														UpperCamelCase__					  =      d_model
														UpperCamelCase__					  =      encoder_ffn_dim
														UpperCamelCase__					  =      encoder_layers
														UpperCamelCase__					  =      encoder_attention_heads
														UpperCamelCase__					  =      decoder_ffn_dim
														UpperCamelCase__					  =      decoder_layers
														UpperCamelCase__					  =      decoder_attention_heads
														UpperCamelCase__					  =      dropout
														UpperCamelCase__					  =      attention_dropout
														UpperCamelCase__					  =      activation_dropout
														UpperCamelCase__					  =      activation_function
														UpperCamelCase__					  =      init_std
														UpperCamelCase__					  =      init_xavier_std
														UpperCamelCase__					  =      encoder_layerdrop
														UpperCamelCase__					  =      auxiliary_loss
														UpperCamelCase__					  =      position_embedding_type
														# deformable attributes
														UpperCamelCase__					  =      num_feature_levels
														UpperCamelCase__					  =      encoder_n_points
														UpperCamelCase__					  =      decoder_n_points
														UpperCamelCase__					  =      two_stage
														UpperCamelCase__					  =      two_stage_num_proposals
														UpperCamelCase__					  =      with_box_refine
														UpperCamelCase__					  =      assign_first_stage
														if two_stage is True and with_box_refine is False:
																					raise ValueError("""If two_stage is True, with_box_refine must be True."""	)
														# Hungarian matcher
														UpperCamelCase__					  =      class_cost
														UpperCamelCase__					  =      bbox_cost
														UpperCamelCase__					  =      giou_cost
														# Loss coefficients
														UpperCamelCase__					  =      mask_loss_coefficient
														UpperCamelCase__					  =      dice_loss_coefficient
														UpperCamelCase__					  =      bbox_loss_coefficient
														UpperCamelCase__					  =      giou_loss_coefficient
														UpperCamelCase__					  =      eos_coefficient
														UpperCamelCase__					  =      focal_alpha
														super().__init__(is_encoder_decoder=__lowerCAmelCase	,			**__lowerCAmelCase	)






							@property
							def 					_lowerCamelCase		(    self	):
														return self.encoder_attention_heads






							@property
							def 					_lowerCamelCase		(    self	):
														return self.d_model







							def 					_lowerCamelCase		(    self	):
														UpperCamelCase__					  =      copy.deepcopy(self.__dict__	)
														UpperCamelCase__					  =      self.backbone_config.to_dict()
														UpperCamelCase__					  =      self.__class__.model_type
														return output











import copy

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


UpperCamelCase__           =			logging.get_logger(__name__)

class 							__SCREAMING_SNAKE_CASE       (  _a							):
							snake_case  :   Optional[Any]      =							"""encoder-decoder"""
							snake_case  :   Optional[int]      =							True






							def __init__(    self	,			**__lowerCAmelCase	):
														super().__init__(**__lowerCAmelCase	)
														assert (
														    "encoder" in kwargs and "decoder" in kwargs
														), "Config has to be initialized with encoder and decoder config"
														UpperCamelCase__					  =      kwargs.pop("""encoder"""	)
														UpperCamelCase__					  =      encoder_config.pop("""model_type"""	)
														UpperCamelCase__					  =      kwargs.pop("""decoder"""	)
														UpperCamelCase__					  =      decoder_config.pop("""model_type"""	)

														from ..auto.configuration_auto import AutoConfig

														UpperCamelCase__					  =      AutoConfig.for_model(__lowerCAmelCase	,			**__lowerCAmelCase	)
														UpperCamelCase__					  =      AutoConfig.for_model(__lowerCAmelCase	,			**__lowerCAmelCase	)
														UpperCamelCase__					  =      True






							@classmethod
							def 					_lowerCamelCase		(    cls	,			__lowerCAmelCase	,			__lowerCAmelCase	,			**__lowerCAmelCase	):
														logger.info("""Set `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config"""	)
														UpperCamelCase__					  =      True
														UpperCamelCase__					  =      True

														return cls(encoder=encoder_config.to_dict()	,			decoder=decoder_config.to_dict()	,			**__lowerCAmelCase	)







							def 					_lowerCamelCase		(    self	):
														UpperCamelCase__					  =      copy.deepcopy(self.__dict__	)
														UpperCamelCase__					  =      self.encoder.to_dict()
														UpperCamelCase__					  =      self.decoder.to_dict()
														UpperCamelCase__					  =      self.__class__.model_type
														return output




