code: def test_k_neighbors_graph_execution(setup):
      rs = np.random.RandomState(0)
      raw_X = rs.rand(10, 5)
      raw_Y = rs.rand(8, 5)
  
      X = mt.tensor(raw_X, chunk_size=7)
      Y = mt.tensor(raw_Y, chunk_size=(5, 3))
  
      neigh = NearestNeighbors(n_neighbors=3)
      neigh.fit(X)
      sklearn_neigh = SkNearestNeighbors(n_neighbors=3)
      sklearn_neigh.fit(raw_X)
  
      for mode in ["connectivity", "distance"]:
          graph = neigh.kneighbors_graph(Y, mode=mode)
          result = graph.fetch()
  
          assert isinstance(result, SparseNDArray)
          assert len(tile(graph).chunks) > 1
  
          expected = sklearn_neigh.kneighbors_graph(raw_Y, mode=mode)
  
          np.testing.assert_array_equal(
              result.toarray(), expected.toarray()
          )
  
          graph2 = neigh.kneighbors_graph(mode=mode)
          result2 = graph2.fetch()
  
          assert isinstance(result2, SparseNDArray)
  
          expected2 = sklearn_neigh.kneighbors_graph(mode=mode)
  
          np.testing.assert_array_equal(
              result2.toarray(), expected2.toarray()
          )
  
      X = [[0], [3], [1]]
  
      neigh = NearestNeighbors(n_neighbors=2)
      sklearn_neigh = SkNearestNeighbors(n_neighbors=2)
      neigh.fit(X)
      sklearn_neigh.fit(X)
  
      A = neigh.kneighbors_graph(X).fetch()
      expected_A = sklearn_neigh.kneighbors_graph(X)
      np.testing.assert_array_equal(A.toarray(), expected_A.toarray())
  
      # test wrong mode
      with pytest.raises(ValueError):
          _ = neigh.kneighbors_graph(mode="unknown")
  
file_path: mars/mars/learn/neighbors/tests/test_nearest_neighbors.py
imports: import numpy
  import scipy.sparse
  import pytest
  from ....None import tensor
  from ....core import tile
  from ....lib.sparse import SparseNDArray
  from ....tests.core import require_cupy
  from ....utils import lazy_import
  from ...proxima.core import proxima
  from ..None import NearestNeighbors
label_desc: Use image node_id 3 for calling a global function with example usage: test_k_neighbors_graph_execution(setup) without return types