class_docstr: Implements the MaskFormer head.
  
  See `Per-Pixel Classification is Not All You Need for Semantic
  Segmentation <https://arxiv.org/pdf/2107.06278>`_ for details.
  
  Args:
      in_channels (list[int]): Number of channels in the input feature map.
      feat_channels (int): Number of channels for feature.
      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.
      pixel_decoder (:obj:`ConfigDict` or dict): Config for pixel
          decoder.
      enforce_decoder_input_project (bool): Whether to add a layer
          to change the embed_dim of transformer encoder in pixel decoder to
          the embed_dim of transformer decoder. Defaults to False.
      transformer_decoder (:obj:`ConfigDict` or dict): Config for
          transformer decoder.
      positional_encoding (:obj:`ConfigDict` or dict): Config for
          transformer decoder position encoding.
      loss_cls (:obj:`ConfigDict` or dict): Config of the classification
          loss. Defaults to `CrossEntropyLoss`.
      loss_mask (:obj:`ConfigDict` or dict): Config of the mask loss.
          Defaults to `FocalLoss`.
      loss_dice (:obj:`ConfigDict` or dict): Config of the dice loss.
          Defaults to `DiceLoss`.
      train_cfg (:obj:`ConfigDict` or dict, optional): Training config of
          MaskFormer head.
      test_cfg (:obj:`ConfigDict` or dict, optional): Testing config of
          MaskFormer head.
      init_cfg (:obj:`ConfigDict` or dict or list[:obj:`ConfigDict` or             dict], optional): Initialization config dict. Defaults to None.
class_docstr_tok: ["Implements","the","MaskFormer","head",".","See","`","Per-Pixel","Classification","is","Not","All","You","Need","for","Semantic","Segmentation","<","https",":","\/\/arxiv.org\/pdf\/2107.06278",">","`","_","for","details",".","Args",":","in_channels","(","list","[","int","]",")",":","Number","of","channels","in","the","input","feature","map",".","feat_channels","(","int",")",":","Number","of","channels","for","feature",".","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",".","pixel_decoder","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","for","pixel","decoder",".","enforce_decoder_input_project","(","bool",")",":","Whether","to","add","a","layer","to","change","the","embed_dim","of","transformer","encoder","in","pixel","decoder","to","the","embed_dim","of","transformer","decoder",".","Defaults","to","False",".","transformer_decoder","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","for","transformer","decoder",".","positional_encoding","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","for","transformer","decoder","position","encoding",".","loss_cls","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","the","classification","loss",".","Defaults","to","`","CrossEntropyLoss","`",".","loss_mask","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","the","mask","loss",".","Defaults","to","`","FocalLoss","`",".","loss_dice","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","the","dice","loss",".","Defaults","to","`","DiceLoss","`",".","train_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Training","config","of","MaskFormer","head",".","test_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Testing","config","of","MaskFormer","head",".","init_cfg","(",":","obj",":","`","ConfigDict","`","or","dict","or","list","[",":","obj",":","`","ConfigDict","`","or","dict","]",",","optional",")",":","Initialization","config","dict",".","Defaults","to","None","."]
docstr: Compute classification and mask targets for all images for a decoder
  layer.
  
  Args:
      cls_scores_list (list[Tensor]): Mask score logits from a single
          decoder layer for all images. Each with shape (num_queries,
          cls_out_channels).
      mask_preds_list (list[Tensor]): Mask logits from a single decoder
          layer for all images. Each with shape (num_queries, h, w).
      batch_gt_instances (list[obj:`InstanceData`]): each contains
          ``labels`` and ``masks``.
      batch_img_metas (list[dict]): List of image meta information.
      return_sampling_results (bool): Whether to return the sampling
          results. Defaults to False.
  
  Returns:
      tuple: a tuple containing the following targets.
  
          - labels_list (list[Tensor]): Labels of all images.                    Each with shape (num_queries, ).
          - label_weights_list (list[Tensor]): Label weights                    of all images. Each with shape (num_queries, ).
          - mask_targets_list (list[Tensor]): Mask targets of                    all images. Each with shape (num_queries, h, w).
          - mask_weights_list (list[Tensor]): Mask weights of                    all images. Each with shape (num_queries, ).
          - avg_factor (int): Average factor that is used to average                    the loss. When using sampling method, avg_factor is
              usually the sum of positive and negative priors. When
              using `MaskPseudoSampler`, `avg_factor` is usually equal
              to the number of positive priors.
  
      additional_returns: This function enables user-defined returns from
          `self._get_targets_single`. These returns are currently refined
          to properties at each feature map (i.e. having HxW dimension).
          The results will be concatenated after the end.
docstr_tok: ["Compute","classification","and","mask","targets","for","all","images","for","a","decoder","layer",".","Args",":","cls_scores_list","(","list","[","Tensor","]",")",":","Mask","score","logits","from","a","single","decoder","layer","for","all","images",".","Each","with","shape","(","num_queries",",","cls_out_channels",")",".","mask_preds_list","(","list","[","Tensor","]",")",":","Mask","logits","from","a","single","decoder","layer","for","all","images",".","Each","with","shape","(","num_queries",",","h",",","w",")",".","batch_gt_instances","(","list","[","obj",":","`","InstanceData","`","]",")",":","each","contains","``","labels","``","and","``","masks","``",".","batch_img_metas","(","list","[","dict","]",")",":","List","of","image","meta","information",".","return_sampling_results","(","bool",")",":","Whether","to","return","the","sampling","results",".","Defaults","to","False",".","Returns",":","tuple",":","a","tuple","containing","the","following","targets",".","-","labels_list","(","list","[","Tensor","]",")",":","Labels","of","all","images",".","Each","with","shape","(","num_queries",",",")",".","-","label_weights_list","(","list","[","Tensor","]",")",":","Label","weights","of","all","images",".","Each","with","shape","(","num_queries",",",")",".","-","mask_targets_list","(","list","[","Tensor","]",")",":","Mask","targets","of","all","images",".","Each","with","shape","(","num_queries",",","h",",","w",")",".","-","mask_weights_list","(","list","[","Tensor","]",")",":","Mask","weights","of","all","images",".","Each","with","shape","(","num_queries",",",")",".","-","avg_factor","(","int",")",":","Average","factor","that","is","used","to","average","the","loss",".","When","using","sampling","method",",","avg_factor","is","usually","the","sum","of","positive","and","negative","priors",".","When","using","`","MaskPseudoSampler","`",",","`","avg_factor","`","is","usually","equal","to","the","number","of","positive","priors",".","additional_returns",":","This","function","enables","user-defined","returns","from","`","self._get_targets_single","`",".","These","returns","are","currently","refined","to","properties","at","each","feature","map","(","i.e",".","having","HxW","dimension",")",".","The","results","will","be","concatenated","after","the","end","."]
code: def get_targets(
      self,
      cls_scores_list: List[Tensor],
      mask_preds_list: List[Tensor],
      batch_gt_instances: InstanceList,
      batch_img_metas: List[dict],
      return_sampling_results: bool = False,
  ) -> Tuple[List[Union[Tensor, int]]]:
      """Compute classification and mask targets for all images for a decoder
          layer.
  
          Args:
              cls_scores_list (list[Tensor]): Mask score logits from a single
                  decoder layer for all images. Each with shape (num_queries,
                  cls_out_channels).
              mask_preds_list (list[Tensor]): Mask logits from a single decoder
                  layer for all images. Each with shape (num_queries, h, w).
              batch_gt_instances (list[obj:`InstanceData`]): each contains
                  ``labels`` and ``masks``.
              batch_img_metas (list[dict]): List of image meta information.
              return_sampling_results (bool): Whether to return the sampling
                  results. Defaults to False.
  
          Returns:
              tuple: a tuple containing the following targets.
  
                  - labels_list (list[Tensor]): Labels of all images.\
                      Each with shape (num_queries, ).
                  - label_weights_list (list[Tensor]): Label weights\
                      of all images. Each with shape (num_queries, ).
                  - mask_targets_list (list[Tensor]): Mask targets of\
                      all images. Each with shape (num_queries, h, w).
                  - mask_weights_list (list[Tensor]): Mask weights of\
                      all images. Each with shape (num_queries, ).
                  - avg_factor (int): Average factor that is used to average\
                      the loss. When using sampling method, avg_factor is
                      usually the sum of positive and negative priors. When
                      using `MaskPseudoSampler`, `avg_factor` is usually equal
                      to the number of positive priors.
  
              additional_returns: This function enables user-defined returns from
                  `self._get_targets_single`. These returns are currently refined
                  to properties at each feature map (i.e. having HxW dimension).
                  The results will be concatenated after the end.
          """
      results = multi_apply(
          self._get_targets_single,
          cls_scores_list,
          mask_preds_list,
          batch_gt_instances,
          batch_img_metas,
      )
      (
          labels_list,
          label_weights_list,
          mask_targets_list,
          mask_weights_list,
          pos_inds_list,
          neg_inds_list,
          sampling_results_list,
      ) = results[:7]
      rest_results = list(results[7:])
  
      avg_factor = sum(
          [results.avg_factor for results in sampling_results_list]
      )
  
      res = (
          labels_list,
          label_weights_list,
          mask_targets_list,
          mask_weights_list,
          avg_factor,
      )
      if return_sampling_results:
          res = res + (sampling_results_list)
  
      return res + tuple(rest_results)
  
imports: from typing import Dict, List, Optional, Tuple, Union
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import Conv2d
  from mmengine.model import caffe2_xavier_init
  from mmengine.structures import InstanceData, PixelData
  from torch import Tensor
  from mmdet.models.layers.pixel_decoder import PixelDecoder
  from mmdet.registry import MODELS, TASK_UTILS
  from mmdet.structures import SampleList
  from mmdet.utils import ConfigType, InstanceList, OptConfigType, OptMultiConfig, reduce_mean
  from ..layers import DetrTransformerDecoder, SinePositionalEncoding
  from ..utils import multi_apply, preprocess_panoptic_gt
  from .anchor_free_head import AnchorFreeHead
label_desc: Use image node_id 4 for calling the MaskFormerHead obj's underlying member method code with example usage: obj.get_targets(cls_scores_list, mask_preds_list, batch_gt_instances, batch_img_metas, return_sampling_results) and returns: unknown