code: def apply_nms_to_single_image_results(
      coords,
      labels,
      scores,
      use_gpu_nms,
      device_id,
      nms_threshold=0.5,
      conf_threshold=0.0,
  ):
      """
      Applies nms to the results for a single image.
  
      Args:
          coords:             (x_min, y_min, x_max, y_max) coordinates for n rois. shape = (n, 4)
          labels:             the predicted label per roi. shape = (n, 1)
          scores:             the predicted score per roi. shape = (n, 1)
          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:
          nmsKeepIndices - the indices of the ROIs to keep after nms
      """
  
      # generate input for nms
      allIndices = []
      nmsRects = [[[]] for _ in range(max(labels) + 1)]
      coordsWithScores = np.hstack((coords, np.array([scores]).T))
      for i in range(max(labels) + 1):
          indices = np.where(np.array(labels) == i)[0]
          nmsRects[i][0] = coordsWithScores[indices, :]
          allIndices.append(indices)
  
      # call nms
      _, nmsKeepIndicesList = apply_nms_to_test_set_results(
          nmsRects,
          nms_threshold,
          conf_threshold,
          use_gpu_nms,
          device_id,
      )
  
      # map back to original roi indices
      nmsKeepIndices = []
      for i in range(max(labels) + 1):
          for keepIndex in nmsKeepIndicesList[i][0]:
              nmsKeepIndices.append(
                  allIndices[i][keepIndex]
              )  # for keepIndex in nmsKeepIndicesList[i][0]]
      assert len(nmsKeepIndices) == len(
          set(nmsKeepIndices)
      )  # check if no roi indices was added >1 times
      return nmsKeepIndices
  
imports: import numpy
  from utils.cython_modules.cpu_nms import cpu_nms
label_desc: Use image node_id 2 for calling a global function with example usage: apply_nms_to_single_image_results(coords, labels, scores, use_gpu_nms, device_id, nms_threshold, conf_threshold) and returns: nmsKeepIndices