code: def apply_nms_to_test_set_results(
      all_boxes, nms_threshold, conf_threshold, use_gpu_nms, device_id
  ):
      """
      Applies nms to the results of multiple images.
  
      Args:
          all_boxes:      shape of all_boxes: e.g. 21 classes x 4952 images x 58 rois x 5 coords+score
          nms_threshold:  the threshold for discarding overlapping ROIs in nms
          conf_threshold: a minimum value for the score of an ROI. ROIs with lower score will be discarded
  
      Returns:
          nms_boxes - the reduced set of rois after nms
          nmsKeepIndices - the indices of the ROIs to keep after nms
      """
  
      num_classes = len(all_boxes)
      num_images = len(all_boxes[0])
      nms_boxes = [
          [[] for _ in range(num_images)] for _ in range(num_classes)
      ]
      nms_keepIndices = [
          [[] for _ in range(num_images)] for _ in range(num_classes)
      ]
      for cls_ind in range(num_classes):
          for im_ind in range(num_images):
              dets = all_boxes[cls_ind][im_ind]
              if len(dets) == 0:
                  continue
              if len(dets) == 1:
                  keep = [0]
              else:
                  keep = nms(
                      dets.astype(np.float32),
                      nms_threshold,
                      use_gpu_nms,
                      device_id,
                  )
  
              # also filter out low confidences
              if conf_threshold > 0:
                  keep_conf_idx = np.where(dets[:, -1] > conf_threshold)
                  keep = list(set(keep_conf_idx[0]).intersection(keep))
  
              if len(keep) == 0:
                  continue
              nms_boxes[cls_ind][im_ind] = dets[keep, :].copy()
              nms_keepIndices[cls_ind][im_ind] = keep
      return nms_boxes, nms_keepIndices
  
imports: import numpy
  from utils.cython_modules.cpu_nms import cpu_nms
label_desc: Use image node_id 3 for calling a global function with example usage: apply_nms_to_test_set_results(all_boxes, nms_threshold, conf_threshold, use_gpu_nms, device_id) and returns: nms_boxes,  nms_keepIndices