code: def test_sum(ctx_factory):
      from pytest import importorskip
  
      importorskip("mako")
  
      context = ctx_factory()
      queue = cl.CommandQueue(context)
  
      n = 200000
      for dtype in [np.float32, np.complex64]:
          a_gpu = general_clrand(queue, (n,), dtype)
  
          a = a_gpu.get()
  
          for slc in [
              slice(None),
              slice(1000, 3000),
              slice(1000, -3000),
              slice(1000, None),
              slice(1000, None, 3),
              slice(1000, 1000),
          ]:
              sum_a = np.sum(a[slc])
  
              if sum_a:
                  ref_divisor = abs(sum_a)
              else:
                  ref_divisor = 1
  
              if slc.step is None:
                  sum_a_gpu = cl.array.sum(a_gpu[slc]).get()
                  assert abs(sum_a_gpu - sum_a) / ref_divisor < 1e-4
  
              sum_a_gpu_2 = cl.array.sum(a_gpu, slice=slc).get()
              assert abs(sum_a_gpu_2 - sum_a) / ref_divisor < 1e-4
  
imports: import numpy
  import numpy.linalg
  import sys
  from pytools import memoize
  from test_array import general_clrand
  import pytest
  import pyopencl
  import pyopencl.array
  from pyopencl.tools import pytest_generate_tests_for_pyopencl
  from pyopencl.characterize import has_double_support, has_struct_arg_count_bug
  from pyopencl.scan import InclusiveScanKernel, ExclusiveScanKernel, GenericScanKernel, GenericDebugScanKernel
  from pyopencl.characterize import get_pocl_version
label_desc: Use image node_id 10 for calling a global function with example usage: test_sum(ctx_factory) without return types