code: public static void nms(List<DetectedObject> objects, double iouThreshold) {
          for (int i = 0; i < objects.size(); i++) {
              for (int j = 0; j < objects.size(); j++) {
                  DetectedObject o1 = objects.get(i);
                  DetectedObject o2 = objects.get(j);
                  if (o1 != null && o2 != null
                          && o1.getPredictedClass() == o2.getPredictedClass()
                          && o1.getConfidence() < o2.getConfidence()
                          && iou(o1, o2) > iouThreshold) {
                      objects.set(i, null);
                  }
              }
          }
          Iterator<DetectedObject> it = objects.iterator();
          while (it.hasNext()) {
              if (it.next() == null) {
                  it.remove();
              }
          }
      }
docs: Performs non-maximum suppression (NMS) on objects, using their IOU with threshold to match pairs.