





"""simple docstring"""





import copy

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


lowercase__				:Dict				   =       logging.get_logger(__name__)

lowercase__				: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 							snake_case							(			__UpperCAmelCase ):

      '''simple docstring'''



      _A     :       str         =       'deformable_detr'
      _A     :       Dict         =       {
          'hidden_size': 'd_model',
          'num_attention_heads': 'encoder_attention_heads',
      }

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

      @property
      def       A_					(							self       :      Optional[int] ):


        '''simple docstring'''




        return self.encoder_attention_heads

      @property
      def       A_					(							self       :      Dict ):


        '''simple docstring'''




        return self.d_model







      def       A_					(							self       :      Dict ):


        '''simple docstring'''




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










"""simple docstring"""





from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available


lowercase__				:Tuple				   =       {
    'configuration_xlm': ['XLM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'XLMConfig', 'XLMOnnxConfig'],
    'tokenization_xlm': ['XLMTokenizer'],
}

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  lowercase__				:Optional[Any]				   =       [
      'XLM_PRETRAINED_MODEL_ARCHIVE_LIST',
      'XLMForMultipleChoice',
      'XLMForQuestionAnswering',
      'XLMForQuestionAnsweringSimple',
      'XLMForSequenceClassification',
      'XLMForTokenClassification',
      'XLMModel',
      'XLMPreTrainedModel',
      'XLMWithLMHeadModel',
  ]

try:
  if not is_tf_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  lowercase__				:List[Any]				   =       [
      'TF_XLM_PRETRAINED_MODEL_ARCHIVE_LIST',
      'TFXLMForMultipleChoice',
      'TFXLMForQuestionAnsweringSimple',
      'TFXLMForSequenceClassification',
      'TFXLMForTokenClassification',
      'TFXLMMainLayer',
      'TFXLMModel',
      'TFXLMPreTrainedModel',
      'TFXLMWithLMHeadModel',
  ]


if TYPE_CHECKING:
  from .configuration_xlm import XLM_PRETRAINED_CONFIG_ARCHIVE_MAP, XLMConfig, XLMOnnxConfig
  from .tokenization_xlm import XLMTokenizer

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_xlm import (
        XLM_PRETRAINED_MODEL_ARCHIVE_LIST,
        XLMForMultipleChoice,
        XLMForQuestionAnswering,
        XLMForQuestionAnsweringSimple,
        XLMForSequenceClassification,
        XLMForTokenClassification,
        XLMModel,
        XLMPreTrainedModel,
        XLMWithLMHeadModel,
    )

  try:
    if not is_tf_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_tf_xlm import (
        TF_XLM_PRETRAINED_MODEL_ARCHIVE_LIST,
        TFXLMForMultipleChoice,
        TFXLMForQuestionAnsweringSimple,
        TFXLMForSequenceClassification,
        TFXLMForTokenClassification,
        TFXLMMainLayer,
        TFXLMModel,
        TFXLMPreTrainedModel,
        TFXLMWithLMHeadModel,
    )

else:
  import sys

  lowercase__				:List[Any]				   =       _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)