code: def test_nms(backend_pair, fargs):
      thre, box_count, normalized, num_zero_boxes = fargs
      x1, y1, x2, y2, score = 0, 1, 2, 3, 4
  
      dets = np.zeros((box_count, 5), dtype=np.float32)
      dets[:, x1] = np.random.random((box_count,)) * 10
      dets[:, x2] = dets[:, x1] + (
          np.random.random((box_count,)) * 10 + 400
      )
      dets[:, y1] = np.random.random((box_count,)) * 10
      dets[:, y2] = dets[:, y1] + (
          np.random.random((box_count,)) * 10 + 600
      )
  
      dets[:, score] = np.sort(np.random.random((box_count,)))[::-1]
  
      dets = np.vstack([dets, np.zeros((num_zero_boxes, 5))])
      ng, nc = backend_pair
  
      # call reference nms
      keep_ref = py_cpu_nms(dets, thre, normalized)
  
      # call cpu nms
      dets_nc = nc.array(dets)
  
      tic_cpu = nc.init_mark()
      toc_cpu = nc.init_mark()
      nc.record_mark(tic_cpu)
  
      keep_nc = nc.nms(dets_nc, thre)
  
      nc.record_mark(toc_cpu)
      nc.synchronize_mark(toc_cpu)
      print(
          "cpu NMS time (ms): {}".format(nc.get_time(tic_cpu, toc_cpu))
      )
  
      assert keep_nc == keep_ref
  
      # call gpu nms kernel, the kernels takes sorted detection boxes
      dets_ng = ng.array(dets)
      scores = dets_ng[:, 4].get()
      order = scores.argsort()[::-1]
  
      sorted_dets_dev = dets_ng[order, :]
  
      tic_gpu = ng.init_mark()
      toc_gpu = ng.init_mark()
  
      # call through backend
      ng.record_mark(tic_gpu)
  
      keep_ng = ng.nms(sorted_dets_dev, thre, normalized)
  
      ng.record_mark(toc_gpu)
      ng.synchronize_mark(toc_gpu)
      print(
          "gpu NMS time (ms): {}".format(ng.get_time(tic_gpu, toc_gpu))
      )
  
      assert keep_ng == keep_ref
  
file_path: neon/tests/test_nms.py
imports: from __future__ import division
  from __future__ import print_function
  from past.utils import old_div
  import itertools
  import numpy
  import pytest
label_desc: Use image node_id 4 for calling a global function with example usage: test_nms(backend_pair, fargs) without return types