code: def test_get_valid_counts():
      def verify_get_valid_counts(
          dshape, score_threshold, id_index, score_index
      ):
          dtype = "float32"
          batch_size, num_anchor, elem_length = dshape
          np_data = np.random.uniform(
              low=-2, high=2, size=dshape
          ).astype(dtype)
          np_out1 = np.zeros(shape=(batch_size,))
          np_out2 = np.zeros(shape=dshape).astype(dtype)
          np_out3 = np.zeros(shape=(batch_size, num_anchor))
          for i in range(batch_size):
              np_out1[i] = 0
              inter_idx = 0
              for j in range(num_anchor):
                  score = np_data[i, j, score_index]
                  if score > score_threshold and (
                      id_index < 0 or np_data[i, j, id_index] >= 0
                  ):
                      for k in range(elem_length):
                          np_out2[i, inter_idx, k] = np_data[i, j, k]
                      np_out1[i] += 1
                      np_out3[i, inter_idx] = j
                      inter_idx += 1
                  if j >= np_out1[i]:
                      for k in range(elem_length):
                          np_out2[i, j, k] = -1.0
                      np_out3[i, j] = -1
  
          x = relay.var("x", relay.ty.TensorType(dshape, dtype))
          z = relay.vision.get_valid_counts(
              x, score_threshold, id_index, score_index
          )
          assert "score_threshold" in z.astext()
          func = relay.Function([x], z.astuple())
          func = run_infer_type(func)
          for target, dev in tvm.testing.enabled_targets():
              out = relay.create_executor(
                  "vm", device=dev, target=target
              ).evaluate(func)(np_data)
  
              tvm.testing.assert_allclose(
                  out[0].numpy(), np_out1, rtol=1e-3, atol=1e-04
              )
              tvm.testing.assert_allclose(
                  out[1].numpy(), np_out2, rtol=1e-3, atol=1e-04
              )
              tvm.testing.assert_allclose(
                  out[2].numpy(), np_out3, rtol=1e-3, atol=1e-04
              )
  
      verify_get_valid_counts((1, 2500, 6), 0, 0, 1)
      verify_get_valid_counts((1, 2500, 5), -1, -1, 0)
      verify_get_valid_counts((3, 1000, 6), 0.55, 1, 0)
      verify_get_valid_counts((16, 500, 5), 0.95, -1, 0)
  
imports: import math
  import platform
  import sys
  import numpy
  import pytest
  import tvm
  import tvm.testing
  import tvm.topi.testing
  from tvm import relay, te
  from tvm.relay.testing import run_infer_type
label_desc: Use image node_id 5 for calling a global function with example usage: test_get_valid_counts() without return types