code: def search_single_scan(index, xq, k, bs=128):
      """performs a search so that the inverted lists are accessed
      sequentially by blocks of size bs"""
  
      # handle pretransform
      if isinstance(index, faiss.IndexPreTransform):
          xq = index.apply_py(xq)
          index = faiss.downcast_index(index.index)
  
      # coarse assignment
      nprobe = min(index.nprobe, index.nlist)
      coarse_dis, assign = index.quantizer.search(xq, nprobe)
      nlist = index.nlist
      assign_buckets = assign // bs
      nq = len(xq)
  
      rh = faiss.ResultHeap(nq, k)
      index.parallel_mode |= index.PARALLEL_MODE_NO_HEAP_INIT
  
      for l0 in range(0, nlist, bs):
          bucket_no = l0 // bs
          skip_rows, skip_cols = np.where(assign_buckets != bucket_no)
          sub_assign = assign.copy()
          sub_assign[skip_rows, skip_cols] = -1
  
          index.search_preassigned(
              xq, k, sub_assign, coarse_dis, D=rh.D, I=rh.I
          )
  
      rh.finalize()
  
      return rh.D, rh.I
  
file_path: faiss/tests/test_ivflib.py
imports: from __future__ import absolute_import, division, print_function
  import unittest
  import faiss
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: search_single_scan(index, xq, k, bs) and returns: rh,  rh