code: def test_override(self):
      d = 256
      nt = 3500
      nb = 10000
      nq = 500
      (xt, xb, xq) = make_binary_dataset(d, nb, nt, nq)
  
      def train_and_get_centroids(override_kmeans_index):
          index = faiss.index_binary_factory(d, "BIVF10")
          index.verbose = True
  
          if override_kmeans_index is not None:
              index.clustering_index = override_kmeans_index
  
          index.train(xt)
  
          centroids = faiss.downcast_IndexBinary(index.quantizer).xb
          return faiss.vector_to_array(centroids).reshape(-1, d // 8)
  
      centroids_ref = train_and_get_centroids(None)
  
      # should do the exact same thing
      centroids_new = train_and_get_centroids(faiss.IndexFlatL2(d))
  
      assert np.all(centroids_ref == centroids_new)
  
      # will do less accurate assignment... Sanity check that the
      # index is indeed used by kmeans
      centroids_new = train_and_get_centroids(faiss.IndexLSH(d, 16))
  
      assert not np.all(centroids_ref == centroids_new)
  
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 1 for calling the TestOverrideKmeansQuantizer obj's underlying member method code with example usage: obj.test_override() and returns: faiss