code: def calculate_uncertainty(logits, classes):
      """
      We estimate uncerainty as L1 distance between 0.0 and the logit prediction in 'logits' for the
          foreground class in `classes`.
      Args:
          logits (Tensor): A tensor of shape (R, C, ...) or (R, 1, ...) for class-specific or
              class-agnostic, where R is the total number of predicted masks in all images and C is
              the number of foreground classes. The values are logits.
          classes (list): A list of length R that contains either predicted of ground truth class
              for eash predicted mask.
      Returns:
          scores (Tensor): A tensor of shape (R, 1, ...) that contains uncertainty scores with
              the most uncertain locations having the highest uncertainty score.
      """
      if logits.shape[1] == 1:
          gt_class_logits = logits.clone()
      else:
          gt_class_logits = logits[
              torch.arange(logits.shape[0], device=logits.device),
              classes,
          ].unsqueeze(1)
      return -(torch.abs(gt_class_logits))
  
imports: import logging
  import math
  import numpy
  from typing import Dict, List, Tuple
  import fvcore.nn.weight_init
  import torch
  from torch import Tensor, nn
  from torch.nn import functional
  from detectron2.config import configurable
  from detectron2.layers import Conv2d, ShapeSpec, cat, interpolate
  from detectron2.modeling import ROI_MASK_HEAD_REGISTRY
  from detectron2.modeling.roi_heads.mask_head import mask_rcnn_inference, mask_rcnn_loss
  from detectron2.structures import Boxes
  from .point_features import generate_regular_grid_point_coords, get_point_coords_wrt_image, get_uncertain_point_coords_on_grid, get_uncertain_point_coords_with_randomness, point_sample, point_sample_fine_grained_features, sample_point_labels
  from .point_head import build_point_head, roi_mask_point_loss
label_desc: Use image node_id 1 for calling a global function with example usage: calculate_uncertainty(logits, classes) and returns: unknown