code: def test_dft(target, dev, inverse, shape, dtype):
      """Test for discrete Fourier transform."""
      implementations = {
          "generic": (
              topi.dft,
              topi.generic.schedule_extern,
          ),
          "gpu": (
              topi.cuda.dft,
              topi.cuda.schedule_extern,
          ),
          "nvptx": (
              topi.cuda.dft,
              topi.cuda.schedule_extern,
          ),
      }
  
      Re = tvm.te.placeholder(shape, dtype=dtype, name="Re")
      Im = tvm.te.placeholder(shape, dtype=dtype, name="Im")
  
      with tvm.target.Target(target):
          fcompute, fschedule = tvm.topi.testing.dispatch(
              target, implementations
          )
  
          outs = fcompute(Re, Im, inverse)
          s = fschedule(outs)
  
          f = tvm.build(s, [Re, Im, *outs], target)
  
      re_np = np.random.normal(size=shape).astype(dtype)
      im_np = np.random.normal(size=shape).astype(dtype)
  
      re = tvm.nd.array(re_np, device=dev)
      im = tvm.nd.array(im_np, device=dev)
      re_out = tvm.nd.array(np.zeros(shape).astype(dtype), device=dev)
      im_out = tvm.nd.array(np.zeros(shape).astype(dtype), device=dev)
  
      f(re, im, re_out, im_out)
  
      re_reference, im_reference = numpy_reference(
          inverse, re_np, im_np
      )
  
      atol = rtol = 1e-3
      if dtype == "float16":
          atol = rtol = 1e-1
  
      tvm.testing.assert_allclose(
          re_out.numpy(), re_reference, rtol=rtol, atol=atol
      )
      tvm.testing.assert_allclose(
          im_out.numpy(), im_reference, rtol=rtol, atol=atol
      )
  
imports: import numpy
  import tvm
  import tvm.testing
  from tvm import topi
  import tvm.topi.testing
label_desc: Use image node_id 2 for calling a global function with example usage: test_dft(target, dev, inverse, shape, dtype) without return types