





'''simple docstring'''


import copy

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


lowerCAmelCase :					Any 							=logging.get_logger(__name__)

lowerCAmelCase :					List[str] 							={
    '''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 				a_       (    _lowerCAmelCase							):
     __A								=      "deformable_detr"
     __A								=      {
         "hidden_size": "d_model",
         "num_attention_heads": "encoder_attention_heads",
     }





     def __init__(			self		: Any     ,				lowercase		: List[Any]=True     ,				lowercase		: Dict=None     ,				lowercase		: Tuple=3     ,				lowercase		: Optional[Any]=300     ,				lowercase		: int=1_024     ,				lowercase		: Tuple=6     ,				lowercase		: str=1_024     ,				lowercase		: Optional[int]=8     ,				lowercase		: Optional[int]=6     ,				lowercase		: List[Any]=1_024     ,				lowercase		: List[str]=8     ,				lowercase		: List[str]=0.0     ,				lowercase		: Dict=True     ,				lowercase		: List[Any]="relu"     ,				lowercase		: Tuple=256     ,				lowercase		: Union[str, Any]=0.1     ,				lowercase		: List[str]=0.0     ,				lowercase		: Dict=0.0     ,				lowercase		: int=0.02     ,				lowercase		: int=1.0     ,				lowercase		: Union[str, Any]=True     ,				lowercase		: List[Any]=False     ,				lowercase		: Any="sine"     ,				lowercase		: Dict="resnet50"     ,				lowercase		: Union[str, Any]=True     ,				lowercase		: Dict=False     ,				lowercase		: List[Any]=4     ,				lowercase		: Dict=4     ,				lowercase		: Optional[int]=4     ,				lowercase		: Optional[int]=False     ,				lowercase		: Dict=300     ,				lowercase		: List[str]=False     ,				lowercase		: Optional[int]=1     ,				lowercase		: Any=5     ,				lowercase		: List[str]=2     ,				lowercase		: Any=1     ,				lowercase		: int=1     ,				lowercase		: Optional[int]=5     ,				lowercase		: str=2     ,				lowercase		: Any=0.1     ,				lowercase		: Any=0.25     ,				lowercase		: List[str]=False     ,				**lowercase		: Union[str, Any]     ,				):





        """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."						)
              lowercase_      :Any         =			CONFIG_MAPPING["resnet"](out_features=["stage4"]						)
           elif isinstance(lowercase     ,				lowercase						):
              lowercase_      :List[Any]         =			backbone_config.get("model_type"						)
              lowercase_      :Union[str, Any]         =			CONFIG_MAPPING[backbone_model_type]
              lowercase_      :Any         =			config_class.from_dict(lowercase						)
        lowercase_      :Dict         =			use_timm_backbone
        lowercase_      :Tuple         =			backbone_config
        lowercase_      :str         =			num_channels
        lowercase_      :Any         =			num_queries
        lowercase_      :Optional[Any]         =			max_position_embeddings
        lowercase_      :Dict         =			d_model
        lowercase_      :Optional[int]         =			encoder_ffn_dim
        lowercase_      :int         =			encoder_layers
        lowercase_      :Any         =			encoder_attention_heads
        lowercase_      :Optional[Any]         =			decoder_ffn_dim
        lowercase_      :List[str]         =			decoder_layers
        lowercase_      :List[Any]         =			decoder_attention_heads
        lowercase_      :str         =			dropout
        lowercase_      :int         =			attention_dropout
        lowercase_      :int         =			activation_dropout
        lowercase_      :List[Any]         =			activation_function
        lowercase_      :int         =			init_std
        lowercase_      :Any         =			init_xavier_std
        lowercase_      :List[Any]         =			encoder_layerdrop
        lowercase_      :Optional[int]         =			auxiliary_loss
        lowercase_      :str         =			position_embedding_type
        lowercase_      :List[Any]         =			backbone
        lowercase_      :Optional[Any]         =			use_pretrained_backbone
        lowercase_      :Union[str, Any]         =			dilation
        # deformable attributes
        lowercase_      :str         =			num_feature_levels
        lowercase_      :Any         =			encoder_n_points
        lowercase_      :Any         =			decoder_n_points
        lowercase_      :Union[str, Any]         =			two_stage
        lowercase_      :Tuple         =			two_stage_num_proposals
        lowercase_      :Optional[Any]         =			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
        lowercase_      :Any         =			class_cost
        lowercase_      :List[str]         =			bbox_cost
        lowercase_      :Tuple         =			giou_cost
        # Loss coefficients
        lowercase_      :Any         =			mask_loss_coefficient
        lowercase_      :Tuple         =			dice_loss_coefficient
        lowercase_      :Optional[int]         =			bbox_loss_coefficient
        lowercase_      :Dict         =			giou_loss_coefficient
        lowercase_      :Dict         =			eos_coefficient
        lowercase_      :List[Any]         =			focal_alpha
        lowercase_      :Any         =			disable_custom_kernels
        super().__init__(is_encoder_decoder=lowercase     ,				**lowercase						)





     @property
     def 							lowercase__				(			self		: str						):





        """simple docstring"""




        return self.encoder_attention_heads





     @property
     def 							lowercase__				(			self		: Optional[Any]						):





        """simple docstring"""




        return self.d_model







     def 							lowercase__				(			self		: Union[str, Any]						):





        """simple docstring"""




        lowercase_      :Optional[Any]         =			copy.deepcopy(self.__dict__						)
        if self.backbone_config is not None:
           lowercase_      :Any         =			self.backbone_config.to_dict()
        lowercase_      :Any         =			self.__class__.model_type
        return output









'''simple docstring'''


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


lowerCAmelCase :					Tuple 							=logging.get_logger(__name__)

lowerCAmelCase :					str 							={
    '''microsoft/cvt-13''': '''https://huggingface.co/microsoft/cvt-13/resolve/main/config.json''',
    # See all Cvt models at https://huggingface.co/models?filter=cvt
}
class 				a_       (    _lowerCAmelCase							):
     __A								=      "cvt"





     def __init__(			self		: Tuple     ,				lowercase		: str=3     ,				lowercase		: str=[7, 3, 3]     ,				lowercase		: List[str]=[4, 2, 2]     ,				lowercase		: Dict=[2, 1, 1]     ,				lowercase		: int=[64, 192, 384]     ,				lowercase		: Dict=[1, 3, 6]     ,				lowercase		: Dict=[1, 2, 10]     ,				lowercase		: Any=[4.0, 4.0, 4.0]     ,				lowercase		: Tuple=[0.0, 0.0, 0.0]     ,				lowercase		: List[str]=[0.0, 0.0, 0.0]     ,				lowercase		: List[str]=[0.0, 0.0, 0.1]     ,				lowercase		: Any=[True, True, True]     ,				lowercase		: Any=[False, False, True]     ,				lowercase		: Optional[Any]=["dw_bn", "dw_bn", "dw_bn"]     ,				lowercase		: int=[3, 3, 3]     ,				lowercase		: str=[1, 1, 1]     ,				lowercase		: List[Any]=[2, 2, 2]     ,				lowercase		: Tuple=[1, 1, 1]     ,				lowercase		: Optional[Any]=[1, 1, 1]     ,				lowercase		: str=0.02     ,				lowercase		: str=1e-1_2     ,				**lowercase		: str     ,				):





        """simple docstring"""




        super().__init__(**lowercase						)
        lowercase_      :List[Any]         =			num_channels
        lowercase_      :Union[str, Any]         =			patch_sizes
        lowercase_      :Tuple         =			patch_stride
        lowercase_      :List[Any]         =			patch_padding
        lowercase_      :List[Any]         =			embed_dim
        lowercase_      :Union[str, Any]         =			num_heads
        lowercase_      :Any         =			depth
        lowercase_      :str         =			mlp_ratio
        lowercase_      :List[str]         =			attention_drop_rate
        lowercase_      :List[Any]         =			drop_rate
        lowercase_      :Union[str, Any]         =			drop_path_rate
        lowercase_      :Any         =			qkv_bias
        lowercase_      :Dict         =			cls_token
        lowercase_      :int         =			qkv_projection_method
        lowercase_      :Union[str, Any]         =			kernel_qkv
        lowercase_      :Optional[Any]         =			padding_kv
        lowercase_      :Optional[Any]         =			stride_kv
        lowercase_      :Dict         =			padding_q
        lowercase_      :Any         =			stride_q
        lowercase_      :Dict         =			initializer_range
        lowercase_      :Optional[Any]         =			layer_norm_eps


