code: def maskrcnn_loss(
      mask_logits, proposals, gt_masks, gt_labels, mask_matched_idxs
  ):
      # type: (Tensor, List[Tensor], List[Tensor], List[Tensor], List[Tensor]) -> Tensor
      """
      Args:
          proposals (list[BoxList])
          mask_logits (Tensor)
          targets (list[BoxList])
  
      Return:
          mask_loss (Tensor): scalar tensor containing the loss
      """
  
      discretization_size = mask_logits.shape[-1]
      labels = [
          gt_label[idxs]
          for gt_label, idxs in zip(gt_labels, mask_matched_idxs)
      ]
      mask_targets = [
          project_masks_on_boxes(m, p, i, discretization_size)
          for m, p, i in zip(gt_masks, proposals, mask_matched_idxs)
      ]
  
      labels = torch.cat(labels, dim=0)
      mask_targets = torch.cat(mask_targets, dim=0)
  
      # torch.mean (in binary_cross_entropy_with_logits) doesn't
      # accept empty tensors, so handle it separately
      if mask_targets.numel() == 0:
          return mask_logits.sum() * 0
  
      mask_loss = F.binary_cross_entropy_with_logits(
          mask_logits[
              torch.arange(labels.shape[0], device=labels.device),
              labels,
          ],
          mask_targets,
      )
      return mask_loss
  
imports: from typing import Dict, List, Optional, Tuple
  import torch
  import torch.nn.functional
  import torchvision
  from torch import nn, Tensor
  from torchvision.ops import boxes, roi_align
  from .None import _utils
label_desc: Use image node_id 4 for calling a global function with example usage: maskrcnn_loss(mask_logits, proposals, gt_masks, gt_labels, mask_matched_idxs) and returns: mask_loss, unknown