code: def filter_range_results(lims, D, I, thresh):
      """select a set of results"""
      nq = lims.size - 1
      mask = D < thresh
      new_lims = np.zeros_like(lims)
      for i in range(nq):
          new_lims[i + 1] = (
              new_lims[i] + mask[lims[i] : lims[i + 1]].sum()
          )
      return new_lims, D[mask], I[mask]
  
imports: import numpy
  import unittest
  import time
  import faiss
  from multiprocessing.pool import ThreadPool
label_desc: Use image node_id 2 for calling a global function with example usage: filter_range_results(lims, D, I, thresh) and returns: new_lims,  D,  I