code: def postprocess_detections(
      self,
      class_logits,  # type: Tensor
      box_regression,  # type: Tensor
      proposals,  # type: List[Tensor]
      image_shapes,  # type: List[Tuple[int, int]]
  ):
      # type: (...) -> Tuple[List[Tensor], List[Tensor], List[Tensor]]
      device = class_logits.device
      num_classes = class_logits.shape[-1]
  
      boxes_per_image = [
          boxes_in_image.shape[0] for boxes_in_image in proposals
      ]
      pred_boxes = self.box_coder.decode(box_regression, proposals)
  
      pred_scores = F.softmax(class_logits, -1)
  
      pred_boxes_list = pred_boxes.split(boxes_per_image, 0)
      pred_scores_list = pred_scores.split(boxes_per_image, 0)
  
      all_boxes = []
      all_scores = []
      all_labels = []
      for boxes, scores, image_shape in zip(
          pred_boxes_list, pred_scores_list, image_shapes
      ):
          boxes = box_ops.clip_boxes_to_image(boxes, image_shape)
  
          # create labels for each prediction
          labels = torch.arange(num_classes, device=device)
          labels = labels.view(1, -1).expand_as(scores)
  
          # remove predictions with the background label
          boxes = boxes[:, 1:]
          scores = scores[:, 1:]
          labels = labels[:, 1:]
  
          # batch everything, by making every class prediction be a separate instance
          boxes = boxes.reshape(-1, 4)
          scores = scores.reshape(-1)
          labels = labels.reshape(-1)
  
          # remove low scoring boxes
          inds = torch.where(scores > self.score_thresh)[0]
          boxes, scores, labels = (
              boxes[inds],
              scores[inds],
              labels[inds],
          )
  
          # remove empty boxes
          keep = box_ops.remove_small_boxes(boxes, min_size=1e-2)
          boxes, scores, labels = (
              boxes[keep],
              scores[keep],
              labels[keep],
          )
  
          # non-maximum suppression, independently done per class
          keep = box_ops.batched_nms(
              boxes, scores, labels, self.nms_thresh
          )
          # keep only topk scoring predictions
          keep = keep[: self.detections_per_img]
          boxes, scores, labels = (
              boxes[keep],
              scores[keep],
              labels[keep],
          )
  
          all_boxes.append(boxes)
          all_scores.append(scores)
          all_labels.append(labels)
  
      return all_boxes, all_scores, all_labels
  
imports: from typing import Dict, List, Optional, Tuple
  import torch
  import torch.nn.functional
  import torchvision
  from torch import nn, Tensor
  from torchvision.ops import boxes, roi_align
  from .None import _utils
label_desc: Use image node_id 9 for calling the RoIHeads obj's underlying member method code with example usage: obj.postprocess_detections(class_logits, box_regression, proposals, image_shapes) and returns: all_boxes,  all_scores,  all_labels