code: def rescoring_mask(scores, mask_pred, masks):
      mask_pred_ = mask_pred.float()
      return scores * (
          (masks * mask_pred_).sum([1, 2])
          / (mask_pred_.sum([1, 2]) + 1e-6)
      )
  
file_path: mmdetection/projects/SparseInst/sparseinst/sparseinst.py
imports: from typing import List, Tuple, Union
  import torch
  import torch.nn.functional
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.models import BaseDetector
  from mmdet.models.utils import unpack_gt_instances
  from mmdet.registry import MODELS
  from mmdet.structures import OptSampleList, SampleList
  from mmdet.utils import ConfigType, OptConfigType
label_desc: Use image node_id 1 for calling a global function with example usage: rescoring_mask(scores, mask_pred, masks) and returns: unknown