code: def hard_nms(box_scores, iou_threshold, top_k=-1, candidate_size=200):
      scores = box_scores[:, -1]
      boxes = box_scores[:, :-1]
      picked = []
      # _, indexes = scores.sort(descending=True)
      indexes = np.argsort(scores)
      # indexes = indexes[:candidate_size]
      indexes = indexes[-candidate_size:]
      while len(indexes) > 0:
          # current = indexes[0]
          current = indexes[-1]
          picked.append(current)
          if 0 < top_k == len(picked) or len(indexes) == 1:
              break
          current_box = boxes[current, :]
          # indexes = indexes[1:]
          indexes = indexes[:-1]
          rest_boxes = boxes[indexes, :]
          iou = iou_of(rest_boxes, np.expand_dims(current_box, axis=0))
          indexes = indexes[iou <= iou_threshold]
      return box_scores[picked, :]
  
file_path: PaddleHub/modules/image/face_detection/ultra_light_fast_generic_face_detector_1mb_640/processor.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import time
  import base64
  import cv2
  import numpy
label_desc: Use image node_id 4 for calling a global function with example usage: hard_nms(box_scores, iou_threshold, top_k, candidate_size) and returns: box_scores