code: def compute_mrcnn_mask_loss(
      target_masks, pred_masks, target_class_ids
  ):
      """
      :param target_masks: (n_sampled_rois, y, x, (z)) A float32 tensor of values 0 or 1. Uses zero padding to fill array.
      :param pred_masks: (n_sampled_rois, n_classes, y, x, (z)) float32 tensor with values between [0, 1].
      :param target_class_ids: (n_sampled_rois)
      :return: loss: torch 1D tensor.
      """
      if 0 not in torch.nonzero(target_class_ids > 0).size():
          # Only positive ROIs contribute to the loss. And only
          # the class specific mask of each ROI.
          positive_ix = torch.nonzero(target_class_ids > 0)[:, 0]
          positive_class_ids = target_class_ids[positive_ix].long()
          y_true = target_masks[positive_ix, :, :].detach()
          y_pred = pred_masks[positive_ix, positive_class_ids, :, :]
          loss = F.binary_cross_entropy(y_pred, y_true)
      else:
          loss = torch.FloatTensor([0]).cuda()
  
      return loss
  
imports: import utils.model_utils
  import utils.exp_utils
  from cuda_functions.nms_2D.pth_nms import nms_gpu
  from cuda_functions.nms_3D.pth_nms import nms_gpu
  from cuda_functions.roi_align_2D.roi_align.crop_and_resize import CropAndResizeFunction
  from cuda_functions.roi_align_3D.roi_align.crop_and_resize import CropAndResizeFunction
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.utils
label_desc: Use image node_id 5 for calling a global function with example usage: compute_mrcnn_mask_loss(target_masks, pred_masks, target_class_ids) and returns: loss