



'''simple docstring'''





import copy

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


_UpperCamelCase											=		logging.get_logger(__name__)

_UpperCamelCase											=		{
    '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_       (							SCREAMING_SNAKE_CASE_	):
  """simple docstring"""




  a_				   ="""deformable_detr"""
  a_				   ={
      """hidden_size""": """d_model""",
      """num_attention_heads""": """encoder_attention_heads""",
  }




  def __init__(					self :      Optional[Any]     ,      _a :      Any=True     ,      _a :      Dict=None     ,      _a :      Optional[Any]=3     ,      _a :      Union[str, Any]=300     ,      _a :      Any=1024     ,      _a :      Dict=6     ,      _a :      Optional[Any]=1024     ,      _a :      Optional[int]=8     ,      _a :      Tuple=6     ,      _a :      str=1024     ,      _a :      str=8     ,      _a :      Optional[int]=0.0     ,      _a :      Optional[Any]=True     ,      _a :      Dict="relu"     ,      _a :      Tuple=256     ,      _a :      Any=0.1     ,      _a :      Any=0.0     ,      _a :      List[str]=0.0     ,      _a :      Dict=0.02     ,      _a :      Optional[Any]=1.0     ,      _a :      str=True     ,      _a :      Any=False     ,      _a :      List[Any]="sine"     ,      _a :      List[Any]="resnet50"     ,      _a :      str=True     ,      _a :      Union[str, Any]=False     ,      _a :      Optional[int]=4     ,      _a :      Dict=4     ,      _a :      Any=4     ,      _a :      Dict=False     ,      _a :      Union[str, Any]=300     ,      _a :      Tuple=False     ,      _a :      Union[str, Any]=1     ,      _a :      Union[str, Any]=5     ,      _a :      Tuple=2     ,      _a :      List[str]=1     ,      _a :      Union[str, Any]=1     ,      _a :      int=5     ,      _a :      Union[str, Any]=2     ,      _a :      int=0.1     ,      _a :      Union[str, Any]=0.25     ,      _a :      List[Any]=False     ,      **_a :      int     ,      )   ->   Tuple:
    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.'  )
        __lowerCamelCase			:			Tuple       			=					CONFIG_MAPPING['resnet'](out_features=['stage4']  )
      elif isinstance(_a     ,      _a  ):
        __lowerCamelCase			:			str       			=					backbone_config.get('model_type'  )
        __lowerCamelCase			:			Tuple       			=					CONFIG_MAPPING[backbone_model_type]
        __lowerCamelCase			:			Dict       			=					config_class.from_dict(_a  )
    __lowerCamelCase			:			Dict       			=					use_timm_backbone
    __lowerCamelCase			:			str       			=					backbone_config
    __lowerCamelCase			:			str       			=					num_channels
    __lowerCamelCase			:			str       			=					num_queries
    __lowerCamelCase			:			Tuple       			=					max_position_embeddings
    __lowerCamelCase			:			Union[str, Any]       			=					d_model
    __lowerCamelCase			:			str       			=					encoder_ffn_dim
    __lowerCamelCase			:			List[Any]       			=					encoder_layers
    __lowerCamelCase			:			List[str]       			=					encoder_attention_heads
    __lowerCamelCase			:			Any       			=					decoder_ffn_dim
    __lowerCamelCase			:			Optional[Any]       			=					decoder_layers
    __lowerCamelCase			:			str       			=					decoder_attention_heads
    __lowerCamelCase			:			Optional[Any]       			=					dropout
    __lowerCamelCase			:			Any       			=					attention_dropout
    __lowerCamelCase			:			Tuple       			=					activation_dropout
    __lowerCamelCase			:			Any       			=					activation_function
    __lowerCamelCase			:			Optional[Any]       			=					init_std
    __lowerCamelCase			:			Optional[Any]       			=					init_xavier_std
    __lowerCamelCase			:			List[str]       			=					encoder_layerdrop
    __lowerCamelCase			:			List[Any]       			=					auxiliary_loss
    __lowerCamelCase			:			Union[str, Any]       			=					position_embedding_type
    __lowerCamelCase			:			Union[str, Any]       			=					backbone
    __lowerCamelCase			:			Union[str, Any]       			=					use_pretrained_backbone
    __lowerCamelCase			:			Tuple       			=					dilation
    # deformable attributes
    __lowerCamelCase			:			str       			=					num_feature_levels
    __lowerCamelCase			:			Dict       			=					encoder_n_points
    __lowerCamelCase			:			str       			=					decoder_n_points
    __lowerCamelCase			:			Tuple       			=					two_stage
    __lowerCamelCase			:			Dict       			=					two_stage_num_proposals
    __lowerCamelCase			:			Dict       			=					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
    __lowerCamelCase			:			Optional[Any]       			=					class_cost
    __lowerCamelCase			:			Optional[int]       			=					bbox_cost
    __lowerCamelCase			:			Optional[Any]       			=					giou_cost
    # Loss coefficients
    __lowerCamelCase			:			Union[str, Any]       			=					mask_loss_coefficient
    __lowerCamelCase			:			List[Any]       			=					dice_loss_coefficient
    __lowerCamelCase			:			List[str]       			=					bbox_loss_coefficient
    __lowerCamelCase			:			Optional[Any]       			=					giou_loss_coefficient
    __lowerCamelCase			:			List[str]       			=					eos_coefficient
    __lowerCamelCase			:			List[Any]       			=					focal_alpha
    __lowerCamelCase			:			Tuple       			=					disable_custom_kernels
    super().__init__(is_encoder_decoder=_a     ,      **_a  )




  @property
  def 		_lowercase	(					self :      int  )   ->   int:
    return self.encoder_attention_heads




  @property
  def 		_lowercase	(					self :      Union[str, Any]  )   ->   int:
    return self.d_model




  def 		_lowercase	(					self :      str  )   ->   Optional[Any]:
    __lowerCamelCase			:			List[Any]       			=					copy.deepcopy(self.__dict__  )
    if self.backbone_config is not None:
      __lowerCamelCase			:			int       			=					self.backbone_config.to_dict()
    __lowerCamelCase			:			Optional[Any]       			=					self.__class__.model_type
    return output











'''simple docstring'''





from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


_UpperCamelCase											=		{'configuration_ibert': ['IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'IBertConfig', 'IBertOnnxConfig']}

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _UpperCamelCase											=		[
       'IBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
       'IBertForMaskedLM',
       'IBertForMultipleChoice',
       'IBertForQuestionAnswering',
       'IBertForSequenceClassification',
       'IBertForTokenClassification',
       'IBertModel',
       'IBertPreTrainedModel',
   ]

if TYPE_CHECKING:
   from .configuration_ibert import IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, IBertConfig, IBertOnnxConfig

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_ibert import (
          IBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
          IBertForMaskedLM,
          IBertForMultipleChoice,
          IBertForQuestionAnswering,
          IBertForSequenceClassification,
          IBertForTokenClassification,
          IBertModel,
          IBertPreTrainedModel,
      )

else:
   import sys

   _UpperCamelCase											=		_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)






