code: def test_transformer_equivalence(nn_data):
      N_NEIGHBORS = 15
      EPSILON = 0.15
      train = nn_data[:400]
      test = nn_data[:200]
  
      # Note we shift N_NEIGHBORS to conform to sklearn's KNeighborTransformer defn
      nnd = NNDescent(
          data=train,
          n_neighbors=N_NEIGHBORS + 1,
          random_state=42,
          compressed=False,
      )
      indices, dists = nnd.query(test, k=N_NEIGHBORS, epsilon=EPSILON)
      sort_idx = np.argsort(indices, axis=1)
      indices_sorted = np.vstack(
          [indices[i, sort_idx[i]] for i in range(sort_idx.shape[0])]
      )
      dists_sorted = np.vstack(
          [dists[i, sort_idx[i]] for i in range(sort_idx.shape[0])]
      )
  
      # Note we shift N_NEIGHBORS to conform to sklearn' KNeighborTransformer defn
      transformer = PyNNDescentTransformer(
          n_neighbors=N_NEIGHBORS,
          search_epsilon=EPSILON,
          random_state=42,
      ).fit(train, compress_index=False)
      Xt = transformer.transform(test).sorted_indices()
  
      assert np.all(Xt.indices == indices_sorted.flatten())
      assert np.allclose(Xt.data, dists_sorted.flat)
  
imports: import os
  import io
  import re
  import pytest
  from contextlib import redirect_stdout
  import numpy
  from sklearn.neighbors import KDTree
  from sklearn.neighbors import NearestNeighbors
  from sklearn.preprocessing import normalize
  import pickle
  import joblib
  import scipy
  from pynndescent import NNDescent, PyNNDescentTransformer
label_desc: Use image node_id 9 for calling a global function with example usage: test_transformer_equivalence(nn_data) without return types