class_docstr: Use a binary index backed by a float index
class_docstr_tok: ["Use","a","binary","index","backed","by","a","float","index"]
code: def test_wrapped_quantizer_HNSW(self):
      def bin2float2d(v):
          n, d = v.shape
          vf = ((v.reshape(-1, 1) >> np.arange(8)) & 1).astype(
              "float32"
          )
          vf *= 2
          vf -= 1
          return vf.reshape(n, d * 8)
  
      d = 256
      nt = 12800
      nb = 10000
      nq = 500
      (xt, xb, xq) = make_binary_dataset(d, nb, nt, nq)
  
      index_ref = faiss.IndexBinaryFlat(d)
  
      index_ref.add(xb)
  
      nlist = 256
      clus = faiss.Clustering(d, nlist)
      clus_index = faiss.IndexFlatL2(d)
  
      xt_f = bin2float2d(xt)
      clus.train(xt_f, clus_index)
  
      centroids = faiss.vector_to_array(clus.centroids).reshape(
          -1, clus.d
      )
      hnsw_quantizer = faiss.IndexHNSWFlat(d, 32)
      hnsw_quantizer.add(centroids)
      hnsw_quantizer.is_trained = True
      wrapped_quantizer = faiss.IndexBinaryFromFloat(hnsw_quantizer)
  
      assert nlist == hnsw_quantizer.ntotal
      assert nlist == wrapped_quantizer.ntotal
      assert wrapped_quantizer.is_trained
  
      index = faiss.IndexBinaryIVF(
          wrapped_quantizer, d, hnsw_quantizer.ntotal
      )
      index.nprobe = 128
  
      assert index.is_trained
  
      index.add(xb)
  
      D_ref, I_ref = index_ref.search(xq, 10)
      D, I = index.search(xq, 10)
  
      recall = sum(
          gti[0] in Di[:10] for gti, Di in zip(D_ref, D)
      ) / float(D_ref.shape[0])
  
      assert recall >= 0.77, "recall = %g" % recall
  
file_path: faiss/tests/test_index_binary_from_float.py
imports: from __future__ import absolute_import, division, print_function
  import numpy
  import unittest
  import faiss
label_desc: Use image node_id 4 for calling the TestIndexBinaryFromFloat obj's underlying member method code with example usage: obj.test_wrapped_quantizer_HNSW() and returns: vf