code: def fast_rcnn_inference(
      boxes: List[torch.Tensor],
      scores: List[torch.Tensor],
      image_shapes: List[Tuple[int, int]],
      score_thresh: float,
      nms_thresh: float,
      topk_per_image: int,
  ):
      """
      Call `fast_rcnn_inference_single_image` for all images.
  
      Args:
          boxes (list[Tensor]): A list of Tensors of predicted class-specific or class-agnostic
              boxes for each image. Element i has shape (Ri, K * 4) if doing
              class-specific regression, or (Ri, 4) if doing class-agnostic
              regression, where Ri is the number of predicted objects for image i.
              This is compatible with the output of :meth:`FastRCNNOutputLayers.predict_boxes`.
          scores (list[Tensor]): A list of Tensors of predicted class scores for each image.
              Element i has shape (Ri, K + 1), where Ri is the number of predicted objects
              for image i. Compatible with the output of :meth:`FastRCNNOutputLayers.predict_probs`.
          image_shapes (list[tuple]): A list of (width, height) tuples for each image in the batch.
          score_thresh (float): Only return detections with a confidence score exceeding this
              threshold.
          nms_thresh (float):  The threshold to use for box non-maximum suppression. Value in [0, 1].
          topk_per_image (int): The number of top scoring detections to return. Set < 0 to return
              all detections.
  
      Returns:
          instances: (list[Instances]): A list of N instances, one for each image in the batch,
              that stores the topk most confidence detections.
          kept_indices: (list[Tensor]): A list of 1D tensor of length of N, each element indicates
              the corresponding boxes/scores index in [0, Ri) from the input, for image i.
      """
      result_per_image = [
          fast_rcnn_inference_single_image(
              boxes_per_image,
              scores_per_image,
              image_shape,
              score_thresh,
              nms_thresh,
              topk_per_image,
          )
          for scores_per_image, boxes_per_image, image_shape in zip(
              scores, boxes, image_shapes
          )
      ]
      return [x[0] for x in result_per_image], [
          x[1] for x in result_per_image
      ]
  
imports: import logging
  from typing import Callable, Dict, List, Optional, Tuple, Union
  import torch
  from torch import nn
  from torch.nn import functional
  from detectron2.config import configurable
  from detectron2.data.detection_utils import get_fed_loss_cls_weights
  from detectron2.layers import ShapeSpec, batched_nms, cat, cross_entropy, nonzero_tuple
  from detectron2.modeling.box_regression import Box2BoxTransform, _dense_box_regression_loss
  from detectron2.structures import Boxes, Instances
  from detectron2.utils.events import get_event_storage
label_desc: Use image node_id 1 for calling a global function with example usage: fast_rcnn_inference(boxes, scores, image_shapes, score_thresh, nms_thresh, topk_per_image) and returns: unknown,  unknown