code: def test_range_search(self):
      d = self.xq.shape[1] * 8
  
      index = faiss.IndexBinaryFlat(d)
      index.add(self.xb)
      D, I = index.search(self.xq, 10)
      thresh = int(np.median(D[:, -1]))
  
      lims, D2, I2 = index.range_search(self.xq, thresh)
      nt1 = nt2 = 0
      for i in range(len(self.xq)):
          range_res = I2[lims[i] : lims[i + 1]]
          if thresh > D[i, -1]:
              self.assertTrue(set(I[i]) <= set(range_res))
              nt1 += 1
          elif thresh < D[i, -1]:
              self.assertTrue(set(range_res) <= set(I[i]))
              nt2 += 1
          # in case of equality we have a problem with ties
      print("nb tests", nt1, nt2)
      # nb tests is actually low...
      self.assertTrue(nt1 > 19 and nt2 > 19)
  
imports: import os
  import numpy
  import unittest
  import faiss
  from common_faiss_tests import compare_binary_result_lists, make_binary_dataset
label_desc: Use image node_id 4 for calling the TestBinaryFlat obj's underlying member method code with example usage: obj.test_range_search() without return types