

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


_lowerCAmelCase  :      Union[str, Any]			 =logging.get_logger(__name__)

_lowerCAmelCase  :      Optional[int]			 ={
    "facebook/dpr-ctx_encoder-single-nq-base": (
        "https://huggingface.co/facebook/dpr-ctx_encoder-single-nq-base/resolve/main/config.json"
    ),
    "facebook/dpr-question_encoder-single-nq-base": (
        "https://huggingface.co/facebook/dpr-question_encoder-single-nq-base/resolve/main/config.json"
    ),
    "facebook/dpr-reader-single-nq-base": (
        "https://huggingface.co/facebook/dpr-reader-single-nq-base/resolve/main/config.json"
    ),
    "facebook/dpr-ctx_encoder-multiset-base": (
        "https://huggingface.co/facebook/dpr-ctx_encoder-multiset-base/resolve/main/config.json"
    ),
    "facebook/dpr-question_encoder-multiset-base": (
        "https://huggingface.co/facebook/dpr-question_encoder-multiset-base/resolve/main/config.json"
    ),
    "facebook/dpr-reader-multiset-base": (
        "https://huggingface.co/facebook/dpr-reader-multiset-base/resolve/main/config.json"
    ),
}

class __UpperCamelCase     (				_a		):






					'''simple docstring'''



					__magic_name__        =   "dpr"





					def __init__(				self				,      lowerCamelCase__=3_0_5_2_2				,      lowerCamelCase__=7_6_8				,      lowerCamelCase__=1_2				,      lowerCamelCase__=1_2				,      lowerCamelCase__=3_0_7_2				,      lowerCamelCase__="gelu"				,      lowerCamelCase__=0.1				,      lowerCamelCase__=0.1				,      lowerCamelCase__=5_1_2				,      lowerCamelCase__=2				,      lowerCamelCase__=0.02				,      lowerCamelCase__=1e-12				,      lowerCamelCase__=0				,      lowerCamelCase__="absolute"				,      lowerCamelCase__ = 0				,      **lowerCamelCase__				,      ):
						super().__init__(pad_token_id=lowerCamelCase__				,      **lowerCamelCase__						)

						UpperCAmelCase__:	Optional[Any]									= vocab_size
						UpperCAmelCase__:	List[Any]									= hidden_size
						UpperCAmelCase__:	str									= num_hidden_layers
						UpperCAmelCase__:	List[str]									= num_attention_heads
						UpperCAmelCase__:	str									= hidden_act
						UpperCAmelCase__:	List[str]									= intermediate_size
						UpperCAmelCase__:	Tuple									= hidden_dropout_prob
						UpperCAmelCase__:	Dict									= attention_probs_dropout_prob
						UpperCAmelCase__:	Optional[int]									= max_position_embeddings
						UpperCAmelCase__:	Tuple									= type_vocab_size
						UpperCAmelCase__:	Dict									= initializer_range
						UpperCAmelCase__:	Any									= layer_norm_eps
						UpperCAmelCase__:	List[str]									= projection_dim
						UpperCAmelCase__:	Union[str, Any]									= position_embedding_type





import copy

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


__UpperCamelCase   :			Any          = logging.get_logger(__name__)

__UpperCamelCase   :			Tuple          = {
    "SenseTime/deformable-detr": "https://huggingface.co/sensetime/deformable-detr/resolve/main/config.json",
    # See all Deformable DETR models at https://huggingface.co/models?filter=deformable-detr
}

class 						__lowerCAmelCase      (      __magic_name__					):
							UpperCamelCase__   	=    '''deformable_detr'''
							UpperCamelCase__   	=    {
							    '''hidden_size''': '''d_model''',
							    '''num_attention_heads''': '''encoder_attention_heads''',
							}
							def __init__(		self		:List[str]						, __magic_name__		:Tuple=True						, __magic_name__		:str=None						, __magic_name__		:Tuple=3						, __magic_name__		:List[str]=300						, __magic_name__		:Dict=1024						, __magic_name__		:Tuple=6						, __magic_name__		:Tuple=1024						, __magic_name__		:int=8						, __magic_name__		:List[Any]=6						, __magic_name__		:Tuple=1024						, __magic_name__		:List[Any]=8						, __magic_name__		:Union[str, Any]=0.0						, __magic_name__		:Union[str, Any]=True						, __magic_name__		:str="relu"						, __magic_name__		:Optional[Any]=256						, __magic_name__		:int=0.1						, __magic_name__		:List[str]=0.0						, __magic_name__		:str=0.0						, __magic_name__		:str=0.02						, __magic_name__		:int=1.0						, __magic_name__		:List[str]=True						, __magic_name__		:Union[str, Any]=False						, __magic_name__		:List[Any]="sine"						, __magic_name__		:Union[str, Any]="resnet50"						, __magic_name__		:int=True						, __magic_name__		:Any=False						, __magic_name__		:List[str]=4						, __magic_name__		:Tuple=4						, __magic_name__		:Union[str, Any]=4						, __magic_name__		:Optional[int]=False						, __magic_name__		:Tuple=300						, __magic_name__		:Tuple=False						, __magic_name__		:List[Any]=1						, __magic_name__		:List[str]=5						, __magic_name__		:List[Any]=2						, __magic_name__		:Optional[int]=1						, __magic_name__		:Union[str, Any]=1						, __magic_name__		:List[Any]=5						, __magic_name__		:Optional[Any]=2						, __magic_name__		:Optional[int]=0.1						, __magic_name__		:List[str]=0.25						, __magic_name__		:str=False						, **__magic_name__		:List[str]						, ):







								'''simple docstring'''







								if backbone_config is not None and use_timm_backbone:
									raise ValueError("""You can't specify both `backbone_config` and `use_timm_backbone`."""							)

								if not use_timm_backbone:
									if backbone_config is None:
										logger.info("""`backbone_config` is `None`. Initializing the config with the default `ResNet` backbone."""							)
										a									=				CONFIG_MAPPING["""resnet"""](out_features=["""stage4"""]							)
									elif isinstance(__magic_name__						, __magic_name__							):
										a									=				backbone_config.get("""model_type"""							)
										a									=				CONFIG_MAPPING[backbone_model_type]
										a									=				config_class.from_dict(__magic_name__							)
								a									=				use_timm_backbone
								a									=				backbone_config
								a									=				num_channels
								a									=				num_queries
								a									=				max_position_embeddings
								a									=				d_model
								a									=				encoder_ffn_dim
								a									=				encoder_layers
								a									=				encoder_attention_heads
								a									=				decoder_ffn_dim
								a									=				decoder_layers
								a									=				decoder_attention_heads
								a									=				dropout
								a									=				attention_dropout
								a									=				activation_dropout
								a									=				activation_function
								a									=				init_std
								a									=				init_xavier_std
								a									=				encoder_layerdrop
								a									=				auxiliary_loss
								a									=				position_embedding_type
								a									=				backbone
								a									=				use_pretrained_backbone
								a									=				dilation
								# deformable attributes
								a									=				num_feature_levels
								a									=				encoder_n_points
								a									=				decoder_n_points
								a									=				two_stage
								a									=				two_stage_num_proposals
								a									=				with_box_refine
								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
								a									=				class_cost
								a									=				bbox_cost
								a									=				giou_cost
								# Loss coefficients
								a									=				mask_loss_coefficient
								a									=				dice_loss_coefficient
								a									=				bbox_loss_coefficient
								a									=				giou_loss_coefficient
								a									=				eos_coefficient
								a									=				focal_alpha
								a									=				disable_custom_kernels
								super().__init__(is_encoder_decoder=__magic_name__						, **__magic_name__							)
							@property
							def  lowerCamelCase__				(		self		:List[Any]							):







								'''simple docstring'''







								return self.encoder_attention_heads
							@property
							def  lowerCamelCase__				(		self		:int							):







								'''simple docstring'''







								return self.d_model





							def  lowerCamelCase__				(		self		:Optional[int]							):







								'''simple docstring'''







								a									=				copy.deepcopy(self.__dict__							)
								if self.backbone_config is not None:
									a									=				self.backbone_config.to_dict()
								a									=				self.__class__.model_type
								return output

