code: def calculate_uncertainty(sem_seg_logits):
      """
      For each location of the prediction `sem_seg_logits` we estimate uncerainty as the
          difference between top first and top second predicted logits.
  
      Args:
          mask_logits (Tensor): A tensor of shape (N, C, ...), where N is the minibatch size and
              C is the number of foreground classes. The values are logits.
  
      Returns:
          scores (Tensor): A tensor of shape (N, 1, ...) that contains uncertainty scores with
              the most uncertain locations having the highest uncertainty score.
      """
      top2_scores = torch.topk(sem_seg_logits, k=2, dim=1)[0]
      return (top2_scores[:, 1] - top2_scores[:, 0]).unsqueeze(1)
  
file_path: detectron2/projects/PointRend/point_rend/semantic_seg.py
imports: import numpy
  from typing import Dict
  import torch
  from torch import nn
  from torch.nn import functional
  from detectron2.layers import ShapeSpec, cat
  from detectron2.modeling import SEM_SEG_HEADS_REGISTRY
  from .point_features import get_uncertain_point_coords_on_grid, get_uncertain_point_coords_with_randomness, point_sample
  from .point_head import build_point_head
label_desc: Use image node_id 1 for calling a global function with example usage: calculate_uncertainty(sem_seg_logits) and returns: unknown