code: def _test_index(
      dataset, exp_accuracy, custom_metric=None, custom_dim=None
  ):
      annoy, dataset_f, dataset = _get_index(
          dataset, custom_metric, custom_dim
      )
  
      n, k = 0, 0
  
      for i, v in enumerate(dataset_f["test"]):
          if custom_dim:
              v = v[:custom_dim]
          js_fast = annoy.get_nns_by_vector(v, 10, 10000)
          js_real = dataset_f["neighbors"][i][:10]
          assert len(js_fast) == 10
          assert len(js_real) == 10
  
          n += 10
          k += len(set(js_fast).intersection(js_real))
  
      accuracy = 100.0 * k / n
      print(
          "%50s accuracy: %5.2f%% (expected %5.2f%%)"
          % (dataset, accuracy, exp_accuracy)
      )
  
      assert accuracy > exp_accuracy - 1.0
  
file_path: annoy/test/accuracy_test.py
imports: from __future__ import print_function
  import os
  import h5py
  from annoy import AnnoyIndex
label_desc: Use image node_id 2 for calling a global function with example usage: _test_index(dataset, exp_accuracy, custom_metric, custom_dim) without return types