

import copy

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


UpperCamelCase__  :      Tuple			=    logging.get_logger(__name__)

UpperCamelCase__  :      Union[str, Any]			=    {
    "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  (    lowerCAmelCase__       ):
  __lowerCAmelCase     :	Dict						 =  'deformable_detr'
  __lowerCAmelCase     :	List[str]						 =  {
      'hidden_size': 'd_model',
      'num_attention_heads': 'encoder_attention_heads',
  }

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

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

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


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





import pytest

import datasets


# Import fixture modules as plugins
UpperCamelCase__  :      Union[str, Any]			=    ["tests.fixtures.files", "tests.fixtures.hub", "tests.fixtures.fsspec"]


def 					_UpperCAmelCase       (  _SCREAMING_SNAKE_CASE					:		Optional[Any] ,   _SCREAMING_SNAKE_CASE					:		Dict       ):





    """simple docstring"""


    for item in items:
        if any(marker in item.keywords for marker in ['integration', 'unit']       ):
            continue
        item.add_marker(pytest.mark.unit       )


def 					_UpperCAmelCase       (  _SCREAMING_SNAKE_CASE					:		Optional[int]       ):





    """simple docstring"""


    config.addinivalue_line('markers' ,   'torchaudio_latest: mark test to run with torchaudio>=0.12'       )


@pytest.fixture(autouse=_SCREAMING_SNAKE_CASE       )
def 					_UpperCAmelCase       (  _SCREAMING_SNAKE_CASE					:		Any ,   _SCREAMING_SNAKE_CASE					:		str       ):





    """simple docstring"""


    SCREAMING_SNAKE_CASE_									=						tmp_path_factory.getbasetemp() / 'cache'
    SCREAMING_SNAKE_CASE_									=						test_hf_cache_home / 'datasets'
    SCREAMING_SNAKE_CASE_									=						test_hf_cache_home / 'metrics'
    SCREAMING_SNAKE_CASE_									=						test_hf_cache_home / 'modules'
    monkeypatch.setattr('datasets.config.HF_DATASETS_CACHE' ,   str(_SCREAMING_SNAKE_CASE       )       )
    monkeypatch.setattr('datasets.config.HF_METRICS_CACHE' ,   str(_SCREAMING_SNAKE_CASE       )       )
    monkeypatch.setattr('datasets.config.HF_MODULES_CACHE' ,   str(_SCREAMING_SNAKE_CASE       )       )
    SCREAMING_SNAKE_CASE_									=						test_hf_datasets_cache / 'downloads'
    monkeypatch.setattr('datasets.config.DOWNLOADED_DATASETS_PATH' ,   str(_SCREAMING_SNAKE_CASE       )       )
    SCREAMING_SNAKE_CASE_									=						test_hf_datasets_cache / 'downloads' / 'extracted'
    monkeypatch.setattr('datasets.config.EXTRACTED_DATASETS_PATH' ,   str(_SCREAMING_SNAKE_CASE       )       )


@pytest.fixture(autouse=_SCREAMING_SNAKE_CASE ,   scope='session'       )
def 					_UpperCAmelCase       (  ):





    """simple docstring"""


    datasets.disable_progress_bar()


@pytest.fixture(autouse=_SCREAMING_SNAKE_CASE       )
def 					_UpperCAmelCase       (  _SCREAMING_SNAKE_CASE					:		Any       ):





    """simple docstring"""


    monkeypatch.setattr('datasets.config.HF_UPDATE_DOWNLOAD_COUNTS' ,   _SCREAMING_SNAKE_CASE       )





@pytest.fixture
def 					_UpperCAmelCase       (  _SCREAMING_SNAKE_CASE					:		Tuple       ):





    """simple docstring"""


    monkeypatch.setattr('sqlalchemy.util.deprecations.SILENCE_UBER_WARNING' ,   _SCREAMING_SNAKE_CASE       )


