class_docstr: Implements the Mask2Former head.
  
  See `Masked-attention Mask Transformer for Universal Image
  Segmentation <https://arxiv.org/pdf/2112.01527>`_ for details.
  
  Args:
      in_channels (list[int]): Number of channels in the input feature map.
      feat_channels (int): Number of channels for features.
      out_channels (int): Number of channels for output.
      num_things_classes (int): Number of things.
      num_stuff_classes (int): Number of stuff.
      num_queries (int): Number of query in Transformer decoder.
      pixel_decoder (:obj:`ConfigDict` or dict): Config for pixel
          decoder. Defaults to None.
      enforce_decoder_input_project (bool, optional): Whether to add
          a layer to change the embed_dim of tranformer encoder in
          pixel decoder to the embed_dim of transformer decoder.
          Defaults to False.
      transformer_decoder (:obj:`ConfigDict` or dict): Config for
          transformer decoder. Defaults to None.
      positional_encoding (:obj:`ConfigDict` or dict): Config for
          transformer decoder position encoding. Defaults to
          dict(num_feats=128, normalize=True).
      loss_cls (:obj:`ConfigDict` or dict): Config of the classification
          loss. Defaults to None.
      loss_mask (:obj:`ConfigDict` or dict): Config of the mask loss.
          Defaults to None.
      loss_dice (:obj:`ConfigDict` or dict): Config of the dice loss.
          Defaults to None.
      train_cfg (:obj:`ConfigDict` or dict, optional): Training config of
          Mask2Former head.
      test_cfg (:obj:`ConfigDict` or dict, optional): Testing config of
          Mask2Former head.
      init_cfg (:obj:`ConfigDict` or dict or list[:obj:`ConfigDict` or             dict], optional): Initialization config dict. Defaults to None.
code: def init_weights(self) -> None:
      for m in self.decoder_input_projs:
          if isinstance(m, Conv2d):
              caffe2_xavier_init(m, bias=0)
  
      self.pixel_decoder.init_weights()
  
      for p in self.transformer_decoder.parameters():
          if p.dim() > 1:
              nn.init.xavier_normal_(p)
  
imports: import copy
  from typing import List, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import Conv2d
  from mmcv.ops import point_sample
  from mmengine.model import ModuleList, caffe2_xavier_init
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.registry import MODELS, TASK_UTILS
  from mmdet.structures import SampleList
  from mmdet.utils import ConfigType, OptConfigType, OptMultiConfig, reduce_mean
  from ..layers import Mask2FormerTransformerDecoder, SinePositionalEncoding
  from ..utils import get_uncertain_point_coords_with_randomness
  from .anchor_free_head import AnchorFreeHead
  from .maskformer_head import MaskFormerHead
label_desc: Use image node_id 2 for calling the Mask2FormerHead obj's underlying member method code with example usage: obj.init_weights() without return types