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:`mmcv.ConfigDict` | 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:`mmcv.ConfigDict` | dict): Config for
          transformer decoder. Defaults to None.
      positional_encoding (:obj:`mmcv.ConfigDict` | dict): Config for
          transformer decoder position encoding. Defaults to None.
      loss_cls (:obj:`mmcv.ConfigDict` | dict): Config of the classification
          loss. Defaults to None.
      loss_mask (:obj:`mmcv.ConfigDict` | dict): Config of the mask loss.
          Defaults to None.
      loss_dice (:obj:`mmcv.ConfigDict` | dict): Config of the dice loss.
          Defaults to None.
      train_cfg (:obj:`mmcv.ConfigDict` | dict): Training config of
          Mask2Former head.
      test_cfg (:obj:`mmcv.ConfigDict` | dict): Testing config of
          Mask2Former head.
      init_cfg (dict or list[dict], optional): Initialization config dict.
          Defaults to None.
class_docstr_tok: ["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",":","`","mmcv.ConfigDict","`","|","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",":","`","mmcv.ConfigDict","`","|","dict",")",":","Config","for","transformer","decoder",".","Defaults","to","None",".","positional_encoding","(",":","obj",":","`","mmcv.ConfigDict","`","|","dict",")",":","Config","for","transformer","decoder","position","encoding",".","Defaults","to","None",".","loss_cls","(",":","obj",":","`","mmcv.ConfigDict","`","|","dict",")",":","Config","of","the","classification","loss",".","Defaults","to","None",".","loss_mask","(",":","obj",":","`","mmcv.ConfigDict","`","|","dict",")",":","Config","of","the","mask","loss",".","Defaults","to","None",".","loss_dice","(",":","obj",":","`","mmcv.ConfigDict","`","|","dict",")",":","Config","of","the","dice","loss",".","Defaults","to","None",".","train_cfg","(",":","obj",":","`","mmcv.ConfigDict","`","|","dict",")",":","Training","config","of","Mask2Former","head",".","test_cfg","(",":","obj",":","`","mmcv.ConfigDict","`","|","dict",")",":","Testing","config","of","Mask2Former","head",".","init_cfg","(","dict","or","list","[","dict","]",",","optional",")",":","Initialization","config","dict",".","Defaults","to","None","."]
docstr: Test segment without test-time aumengtation.
  
  Only the output of last decoder layers was used.
  
  Args:
      inputs (list[Tensor]): Multi-level features from the
          upstream network, each is a 4D-tensor.
      img_metas (list[dict]): List of image information.
      test_cfg (dict): Testing config.
  
  Returns:
      seg_mask (Tensor): Predicted semantic segmentation logits.
docstr_tok: ["Test","segment","without","test-time","aumengtation",".","Only","the","output","of","last","decoder","layers","was","used",".","Args",":","inputs","(","list","[","Tensor","]",")",":","Multi-level","features","from","the","upstream","network",",","each","is","a","4D-tensor",".","img_metas","(","list","[","dict","]",")",":","List","of","image","information",".","test_cfg","(","dict",")",":","Testing","config",".","Returns",":","seg_mask","(","Tensor",")",":","Predicted","semantic","segmentation","logits","."]
code: def forward_test(self, inputs, img_metas, test_cfg):
      """Test segment without test-time aumengtation.
  
      Only the output of last decoder layers was used.
  
      Args:
          inputs (list[Tensor]): Multi-level features from the
              upstream network, each is a 4D-tensor.
          img_metas (list[dict]): List of image information.
          test_cfg (dict): Testing config.
  
      Returns:
          seg_mask (Tensor): Predicted semantic segmentation logits.
      """
      all_cls_scores, all_mask_preds = self(inputs, img_metas)
      cls_score, mask_pred = all_cls_scores[-1], all_mask_preds[-1]
      ori_h, ori_w, _ = img_metas[0]["ori_shape"]
  
      # semantic inference
      cls_score = F.softmax(cls_score, dim=-1)[..., :-1]
      mask_pred = mask_pred.sigmoid()
      seg_mask = torch.einsum("bqc,bqhw->bchw", cls_score, mask_pred)
      return seg_mask
  
imports: import copy
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import Conv2d, build_plugin_layer, caffe2_xavier_init
  from mmcv.cnn.bricks.transformer import build_positional_encoding, build_transformer_layer_sequence
  from mmcv.ops import point_sample
  from mmcv.runner import ModuleList, force_fp32
  from mmseg.models.builder import HEADS, build_loss
  from mmseg.models.decode_heads.decode_head import BaseDecodeHead
  from ...core import build_sampler, multi_apply, reduce_mean
  from ..builder import build_assigner
  from ..utils import get_uncertain_point_coords_with_randomness
label_desc: Use image node_id 10 for calling the Mask2FormerHead obj's underlying member method code with example usage: obj.forward_test(inputs, img_metas, test_cfg) and returns: seg_mask