class_docstr: Detection Head of RTMDet-Ins.
  
  Args:
      num_prototypes (int): Number of mask prototype features extracted
          from the mask head. Defaults to 8.
      dyconv_channels (int): Channel of the dynamic conv layers.
          Defaults to 8.
      num_dyconvs (int): Number of the dynamic convolution layers.
          Defaults to 3.
      mask_loss_stride (int): Down sample stride of the masks for loss
          computation. Defaults to 4.
      loss_mask (:obj:`ConfigDict` or dict): Config dict for mask loss.
docstr: Compute instance segmentation loss.
  
  Args:
      mask_feats (list[Tensor]): Mask prototype features extracted from
          the mask head. Has shape (N, num_prototypes, H, W)
      flatten_kernels (list[Tensor]): Kernels of the dynamic conv layers.
          Has shape (N, num_instances, num_params)
      sampling_results_list (list[:obj:`SamplingResults`]) Batch of
          assignment results.
      batch_gt_instances (list[:obj:`InstanceData`]): Batch of
          gt_instance.  It usually includes ``bboxes`` and ``labels``
          attributes.
  
  Returns:
      Tensor: The mask loss tensor.
code: def loss_mask_by_feat(
      self,
      mask_feats: Tensor,
      flatten_kernels: Tensor,
      sampling_results_list: list,
      batch_gt_instances: InstanceList,
  ) -> Tensor:
      """Compute instance segmentation loss.
  
      Args:
          mask_feats (list[Tensor]): Mask prototype features extracted from
              the mask head. Has shape (N, num_prototypes, H, W)
          flatten_kernels (list[Tensor]): Kernels of the dynamic conv layers.
              Has shape (N, num_instances, num_params)
          sampling_results_list (list[:obj:`SamplingResults`]) Batch of
              assignment results.
          batch_gt_instances (list[:obj:`InstanceData`]): Batch of
              gt_instance.  It usually includes ``bboxes`` and ``labels``
              attributes.
  
      Returns:
          Tensor: The mask loss tensor.
      """
      batch_pos_mask_logits = []
      pos_gt_masks = []
      for idx, (
          mask_feat,
          kernels,
          sampling_results,
          gt_instances,
      ) in enumerate(
          zip(
              mask_feats,
              flatten_kernels,
              sampling_results_list,
              batch_gt_instances,
          )
      ):
          pos_priors = sampling_results.pos_priors
          pos_inds = sampling_results.pos_inds
          pos_kernels = kernels[pos_inds]  # n_pos, num_gen_params
          pos_mask_logits = self._mask_predict_by_feat_single(
              mask_feat, pos_kernels, pos_priors
          )
          if gt_instances.masks.numel() == 0:
              gt_masks = torch.empty_like(gt_instances.masks)
          else:
              gt_masks = gt_instances.masks[
                  sampling_results.pos_assigned_gt_inds, :
              ]
          batch_pos_mask_logits.append(pos_mask_logits)
          pos_gt_masks.append(gt_masks)
  
      pos_gt_masks = torch.cat(pos_gt_masks, 0)
      batch_pos_mask_logits = torch.cat(batch_pos_mask_logits, 0)
  
      # avg_factor
      num_pos = batch_pos_mask_logits.shape[0]
      num_pos = (
          reduce_mean(mask_feats.new_tensor([num_pos]))
          .clamp_(min=1)
          .item()
      )
  
      if batch_pos_mask_logits.shape[0] == 0:
          return mask_feats.sum() * 0
  
      scale = (
          self.prior_generator.strides[0][0] // self.mask_loss_stride
      )
      # upsample pred masks
      batch_pos_mask_logits = F.interpolate(
          batch_pos_mask_logits.unsqueeze(0),
          scale_factor=scale,
          mode="bilinear",
          align_corners=False,
      ).squeeze(0)
      # downsample gt masks
      pos_gt_masks = pos_gt_masks[
          :,
          self.mask_loss_stride // 2 :: self.mask_loss_stride,
          self.mask_loss_stride // 2 :: self.mask_loss_stride,
      ]
  
      loss_mask = self.loss_mask(
          batch_pos_mask_logits,
          pos_gt_masks,
          weight=None,
          avg_factor=num_pos,
      )
  
      return loss_mask
  
imports: import copy
  import math
  from typing import List, Optional, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import ConvModule, is_norm
  from mmcv.ops import batched_nms
  from mmengine.model import BaseModule, bias_init_with_prob, constant_init, normal_init
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.models.layers.transformer import inverse_sigmoid
  from mmdet.models.utils import filter_scores_and_topk, multi_apply, select_single_mlvl, sigmoid_geometric_mean
  from mmdet.registry import MODELS
  from mmdet.structures.bbox import cat_boxes, distance2bbox, get_box_tensor, get_box_wh, scale_boxes
  from mmdet.utils import ConfigType, InstanceList, OptInstanceList, reduce_mean
  from .rtmdet_head import RTMDetHead
label_desc: Use image node_id 9 for calling the RTMDetInsHead obj's underlying member method code with example usage: obj.loss_mask_by_feat(mask_feats, flatten_kernels, sampling_results_list, batch_gt_instances) and returns: loss_mask, unknown