code: def test_matrix_nms(self):
      N, M, C = 7, 1200, 21
      BOX_SIZE = 4
      nms_top_k = 400
      keep_top_k = 200
      score_threshold = 0.01
      post_threshold = 0.0
  
      scores_np = np.random.random((N * M, C)).astype("float32")
      scores_np = np.apply_along_axis(softmax, 1, scores_np)
      scores_np = np.reshape(scores_np, (N, M, C))
      scores_np = np.transpose(scores_np, (0, 2, 1))
  
      boxes_np = np.random.random((N, M, BOX_SIZE)).astype("float32")
      boxes_np[:, :, 0:2] = boxes_np[:, :, 0:2] * 0.5
      boxes_np[:, :, 2:4] = boxes_np[:, :, 2:4] * 0.5 + 0.5
  
      with self.static_graph():
          boxes = paddle.static.data(
              name="boxes", shape=[N, M, BOX_SIZE], dtype="float32"
          )
          scores = paddle.static.data(
              name="scores", shape=[N, C, M], dtype="float32"
          )
          out, index, _ = ops.matrix_nms(
              bboxes=boxes,
              scores=scores,
              score_threshold=score_threshold,
              post_threshold=post_threshold,
              nms_top_k=nms_top_k,
              keep_top_k=keep_top_k,
              return_index=True,
          )
          out_np, index_np = self.get_static_graph_result(
              feed={"boxes": boxes_np, "scores": scores_np},
              fetch_list=[out, index],
              with_lod=True,
          )
  
      with self.dynamic_graph():
          boxes_dy = paddle.to_tensor(boxes_np)
          scores_dy = paddle.to_tensor(scores_np)
  
          out_dy, index_dy, _ = ops.matrix_nms(
              bboxes=boxes_dy,
              scores=scores_dy,
              score_threshold=score_threshold,
              post_threshold=post_threshold,
              nms_top_k=nms_top_k,
              keep_top_k=keep_top_k,
              return_index=True,
          )
          out_dy_np = out_dy.numpy()
          index_dy_np = index_dy.numpy()
  
      self.assertTrue(np.array_equal(out_np, out_dy_np))
      self.assertTrue(np.array_equal(index_np, index_dy_np))
  
imports: from __future__ import print_function
  import os, sys
  import unittest
  import numpy
  import paddle
  import ppdet.modeling.ops
  from ppdet.modeling.tests.test_base import LayerTest
label_desc: Use image node_id 1 for calling the TestMatrixNMS obj's underlying member method code with example usage: obj.test_matrix_nms() without return types