code: def test_key_value_sorter(ctx_factory):
      from pytest import importorskip
  
      importorskip("mako")
  
      context = ctx_factory()
      queue = cl.CommandQueue(context)
  
      n = 10**5
      nkeys = 2000
      from pyopencl.clrandom import rand as clrand
  
      keys = clrand(queue, n, np.int32, b=nkeys)
      values = clrand(queue, n, np.int32, b=n).astype(np.int64)
  
      assert np.max(keys.get()) < nkeys
  
      from pyopencl.algorithm import KeyValueSorter
  
      kvs = KeyValueSorter(context)
      starts, lists, evt = kvs(
          queue, keys, values, nkeys, starts_dtype=np.int32
      )
  
      starts = starts.get()
      lists = lists.get()
  
      mydict = {}
      for k, v in zip(keys.get(), values.get()):
          mydict.setdefault(k, []).append(v)
  
      for i in range(nkeys):
          start, end = starts[i : i + 2]
          assert sorted(mydict[i]) == sorted(lists[start:end])
  
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 31 for calling a global function with example usage: test_key_value_sorter(ctx_factory) without return types