code: def test_scan(ctx_factory, dtype, scan_cls):
      from pytest import importorskip
  
      importorskip("mako")
  
      context = ctx_factory()
      queue = cl.CommandQueue(context)
  
      knl = scan_cls(context, dtype, "a+b", "0")
  
      rng = np.random.default_rng(seed=42)
      for n in scan_test_counts:
          host_data = rng.integers(0, 10, n, dtype=dtype)
          dev_data = cl.array.to_device(queue, host_data)
  
          # /!\ fails on Nv GT2?? for some drivers
          assert (host_data == dev_data.get()).all()
  
          knl(dev_data)
  
          desired_result = np.cumsum(host_data, axis=0)
          if scan_cls is ExclusiveScanKernel:
              desired_result -= host_data
  
          is_ok = (dev_data.get() == desired_result).all()
          if 1 and not is_ok:
              print("something went wrong, summarizing error...")
              print(
                  summarize_error(
                      dev_data.get(), desired_result, host_data
                  )
              )
  
          print(
              "dtype:%s n:%d %s worked:%s" % (dtype, n, scan_cls, is_ok)
          )
          assert is_ok
          from gc import collect
  
          collect()
  
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 19 for calling a global function with example usage: test_scan(ctx_factory, dtype, scan_cls) without return types