class_docstr: Implementation of `DAB-DETR:
  Dynamic Anchor Boxes are Better Queries for DETR.
  
  <https://arxiv.org/abs/2201.12329>`_.
  
  Code is modified from the `official github repo
  <https://github.com/IDEA-Research/DAB-DETR>`_.
  
  Args:
      with_random_refpoints (bool): Whether to randomly initialize query
          embeddings and not update them during training.
          Defaults to False.
      num_patterns (int): Inspired by Anchor-DETR. Defaults to 0.
class_docstr_tok: ["Implementation","of","`","DAB-DETR",":","Dynamic","Anchor","Boxes","are","Better","Queries","for","DETR",".","<","https",":","\/\/arxiv.org\/abs\/2201.12329",">","`","_",".","Code","is","modified","from","the","`","official","github","repo","<","https",":","\/\/github.com\/IDEA-Research\/DAB-DETR",">","`","_",".","Args",":","with_random_refpoints","(","bool",")",":","Whether","to","randomly","initialize","query","embeddings","and","not","update","them","during","training",".","Defaults","to","False",".","num_patterns","(","int",")",":","Inspired","by","Anchor-DETR",".","Defaults","to","0","."]
docstr: Initialize layers except for backbone, neck and bbox_head.
docstr_tok: ["Initialize","layers","except","for","backbone",",","neck","and","bbox_head","."]
code: def _init_layers(self) -> None:
      """Initialize layers except for backbone, neck and bbox_head."""
      self.positional_encoding = SinePositionalEncoding(
          **self.positional_encoding
      )
      self.encoder = DABDetrTransformerEncoder(**self.encoder)
      self.decoder = DABDetrTransformerDecoder(**self.decoder)
      self.embed_dims = self.encoder.embed_dims
      self.query_dim = self.decoder.query_dim
      self.query_embedding = nn.Embedding(
          self.num_queries, self.query_dim
      )
      if self.num_patterns > 0:
          self.patterns = nn.Embedding(
              self.num_patterns, self.embed_dims
          )
  
      num_feats = self.positional_encoding.num_feats
      assert num_feats * 2 == self.embed_dims, (
          f"embed_dims should be exactly 2 times of num_feats. "
          f"Found {self.embed_dims} and {num_feats}."
      )
  
file_path: mmdetection/mmdet/models/detectors/dab_detr.py
imports: from typing import Dict, Tuple
  from mmengine.model import uniform_init
  from torch import Tensor, nn
  from mmdet.registry import MODELS
  from ..layers import SinePositionalEncoding
  from ..layers.transformer import DABDetrTransformerDecoder, DABDetrTransformerEncoder, inverse_sigmoid
  from .detr import DETR
label_desc: Use image node_id 2 for calling the DABDETR obj's underlying member method code with example usage: obj._init_layers() without return types