class_docstr: Pixel decoder with multi-scale deformable attention.
  
  Args:
      in_channels (list[int] | tuple[int]): Number of channels in the
          input feature maps.
      strides (list[int] | tuple[int]): Output strides of feature from
          backbone.
      feat_channels (int): Number of channels for feature.
      out_channels (int): Number of channels for output.
      num_outs (int): Number of output scales.
      norm_cfg (:obj:`ConfigDict` or dict): Config for normalization.
          Defaults to dict(type='GN', num_groups=32).
      act_cfg (:obj:`ConfigDict` or dict): Config for activation.
          Defaults to dict(type='ReLU').
      encoder (:obj:`ConfigDict` or dict): Config for transformer
          encoder. Defaults to None.
      positional_encoding (:obj:`ConfigDict` or dict): Config for
          transformer encoder position encoding. Defaults to
          dict(num_feats=128, normalize=True).
      init_cfg (:obj:`ConfigDict` or dict or list[:obj:`ConfigDict` or             dict], optional): Initialization config dict. Defaults to None.
class_docstr_tok: ["Pixel","decoder","with","multi-scale","deformable","attention",".","Args",":","in_channels","(","list","[","int","]","|","tuple","[","int","]",")",":","Number","of","channels","in","the","input","feature","maps",".","strides","(","list","[","int","]","|","tuple","[","int","]",")",":","Output","strides","of","feature","from","backbone",".","feat_channels","(","int",")",":","Number","of","channels","for","feature",".","out_channels","(","int",")",":","Number","of","channels","for","output",".","num_outs","(","int",")",":","Number","of","output","scales",".","norm_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","for","normalization",".","Defaults","to","dict","(","type='GN","'",",","num_groups=32",")",".","act_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","for","activation",".","Defaults","to","dict","(","type='ReLU","'",")",".","encoder","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","for","transformer","encoder",".","Defaults","to","None",".","positional_encoding","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","for","transformer","encoder","position","encoding",".","Defaults","to","dict","(","num_feats=128",",","normalize=True",")",".","init_cfg","(",":","obj",":","`","ConfigDict","`","or","dict","or","list","[",":","obj",":","`","ConfigDict","`","or","dict","]",",","optional",")",":","Initialization","config","dict",".","Defaults","to","None","."]
docstr: Initialize weights.
docstr_tok: ["Initialize","weights","."]
code: def init_weights(self) -> None:
      """Initialize weights."""
      for i in range(0, self.num_encoder_levels):
          xavier_init(
              self.input_convs[i].conv,
              gain=1,
              bias=0,
              distribution="uniform",
          )
  
      for i in range(
          0, self.num_input_levels - self.num_encoder_levels
      ):
          caffe2_xavier_init(self.lateral_convs[i].conv, bias=0)
          caffe2_xavier_init(self.output_convs[i].conv, bias=0)
  
      caffe2_xavier_init(self.mask_feature, bias=0)
  
      normal_init(self.level_encoding, mean=0, std=1)
      for p in self.encoder.parameters():
          if p.dim() > 1:
              nn.init.xavier_normal_(p)
  
      # init_weights defined in MultiScaleDeformableAttention
      for m in self.encoder.layers.modules():
          if isinstance(m, MultiScaleDeformableAttention):
              m.init_weights()
  
file_path: mmdetection/mmdet/models/layers/msdeformattn_pixel_decoder.py
imports: from typing import List, Tuple, Union
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import Conv2d, ConvModule
  from mmcv.cnn.bricks.transformer import MultiScaleDeformableAttention
  from mmengine.model import BaseModule, ModuleList, caffe2_xavier_init, normal_init, xavier_init
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.utils import ConfigType, OptMultiConfig
  from ..task_modules.prior_generators import MlvlPointGenerator
  from .positional_encoding import SinePositionalEncoding
  from .transformer import Mask2FormerTransformerEncoder
label_desc: Use image node_id 2 for calling the MSDeformAttnPixelDecoder obj's underlying member method code with example usage: obj.init_weights() without return types