code: def do_test_knn_and_range(self, factory, range=True):
      ds = datasets.SyntheticDataset(32, 10000, 100, 20)
      index = faiss.index_factory(ds.d, factory)
      index.train(ds.get_train())
      index.add(ds.get_database())
      index.nprobe = 5
      Dref, Iref = index.search(ds.get_queries(), 10)
  
      Dq, Iq = index.quantizer.search(ds.get_queries(), index.nprobe)
      Dnew, Inew = index.search_preassigned(
          ds.get_queries(), 10, Iq, Dq
      )
      np.testing.assert_equal(Iref, Inew)
      np.testing.assert_allclose(Dref, Dnew, atol=1e-5)
  
      if range:
          r2 = float(np.median(Dref[:, 5]))
          Lref, Dref, Iref = index.range_search(ds.get_queries(), r2)
          assert (
              Lref.size > 10
          )  # make sure there is something to test...
  
          Lnew, Dnew, Inew = index.range_search_preassigned(
              ds.get_queries(), r2, Iq, Dq
          )
          check_ref_range_results(Lref, Dref, Iref, Lnew, Dnew, Inew)
  
imports: import numpy
  import faiss
  import unittest
  import sys
  import gc
  from faiss.contrib import datasets
  from faiss.contrib.evaluation import sort_range_res_2, check_ref_range_results
label_desc: Use image node_id 1 for calling the TestPrecomputed obj's underlying member method code with example usage: obj.do_test_knn_and_range(factory, range) without return types