code: def caffe2_mask_rcnn_inference(pred_mask_logits, pred_instances):
      """equivalent to mask_head.mask_rcnn_inference"""
      if all(isinstance(x, InstancesList) for x in pred_instances):
          assert len(pred_instances) == 1
          mask_probs_pred = pred_mask_logits.sigmoid()
          mask_probs_pred = alias(mask_probs_pred, "mask_fcn_probs")
          pred_instances[0].set("pred_masks", mask_probs_pred)
      else:
          mask_rcnn_inference(pred_mask_logits, pred_instances)
  
imports: import math
  from typing import Dict
  import torch
  import torch.nn.functional
  from detectron2.layers import ShapeSpec, cat
  from detectron2.layers.roi_align_rotated import ROIAlignRotated
  from detectron2.modeling import poolers
  from detectron2.modeling.proposal_generator import rpn
  from detectron2.modeling.roi_heads.mask_head import mask_rcnn_inference
  from detectron2.structures import Boxes, ImageList, Instances, Keypoints, RotatedBoxes
  from .shared import alias, to_device
label_desc: Use image node_id 2 for calling a global function with example usage: caffe2_mask_rcnn_inference(pred_mask_logits, pred_instances) without return types