code: def _check_knn_queries(
      items, queries, k=5, max_temp_memory=500_000_000
  ):
      # compute distances on the gpu
      knn = implicit.gpu._cuda.KnnQuery(max_temp_memory=max_temp_memory)
      ids, distances = knn.topk(
          implicit.gpu._cuda.Matrix(items),
          implicit.gpu._cuda.Matrix(queries),
          k,
      )
  
      # compute on the cpu
      batch = queries.dot(items.T)
      exact_ids = np.flip(np.argsort(batch)[:, -k:], axis=1)
      exact_distances = np.zeros(exact_ids.shape)
      for r in range(batch.shape[0]):
          exact_distances[r] = batch[r][exact_ids[r]]
  
      # make sure that we match
      assert_allclose(distances, exact_distances, rtol=1e-06)
      assert_array_equal(ids, exact_ids)
  
file_path: implicit/tests/gpu_test.py
imports: import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal
  from recommender_base_test import get_checker_board
  import implicit
label_desc: Use image node_id 3 for calling a global function with example usage: _check_knn_queries(items, queries, k, max_temp_memory) without return types