code: def make_unary_function_test(
      name, a=0, b=1, threshold=0, complex=False
  ):
      def test():
          gpu_func = getattr(cumath, name)
          cpu_func = getattr(np, numpy_func_names.get(name, name))
          if complex:
              _dtypes = complex_dtypes
          else:
              _dtypes = dtypes
  
          for s in sizes:
              for dtype in _dtypes:
                  np.random.seed(1)
                  A = (np.random.random(s) * (b - a) + a).astype(dtype)
                  if complex:
                      A += (np.random.random(s) * (b - a) + a) * 1j
  
                  args = gpuarray.to_gpu(A)
                  gpu_results = gpu_func(args).get()
                  cpu_results = cpu_func(A)
  
                  max_err = np.max(np.abs(cpu_results - gpu_results))
                  assert (max_err <= threshold).all(), (
                      max_err,
                      name,
                      dtype,
                  )
  
                  gpu_results2 = gpuarray.empty_like(args)
                  gr2 = gpu_func(args, out=gpu_results2)
                  assert gpu_results2 is gr2
                  gr2 = gr2.get()
                  max_err = np.max(np.abs(cpu_results - gr2))
                  assert (max_err <= threshold).all(), (
                      max_err,
                      name,
                      dtype,
                  )
  
      return mark_cuda_test(test)
  
file_path: pycuda/test/test_cumath.py
imports: import math
  import numpy
  from pycuda.tools import mark_cuda_test
  import pycuda.gpuarray
  import pycuda.driver
  import pycuda.cumath
label_desc: Use image node_id 1 for calling a global function with example usage: make_unary_function_test(name, a, b, threshold, complex) and returns: mark_cuda_test