code: def test_encoded(self):
      d = 32
      k = 5
      xt, xb, xq = get_dataset_2(d, 1000, 0, 0)
  
      # make sure that training on a compressed then decompressed
      # dataset gives the same result as decompressing on-the-fly
  
      codec = faiss.IndexScalarQuantizer(
          d, faiss.ScalarQuantizer.QT_4bit
      )
      codec.train(xt)
      codes = codec.sa_encode(xt)
  
      xt2 = codec.sa_decode(codes)
  
      clus = faiss.Clustering(d, k)
      # clus.verbose = True
      clus.niter = 0
      index = faiss.IndexFlatL2(d)
      clus.train(xt2, index)
      ref_centroids = faiss.vector_to_array(clus.centroids).reshape(
          -1, d
      )
  
      _, ref_errs = index.search(xt2, 1)
  
      clus = faiss.Clustering(d, k)
      # clus.verbose = True
      clus.niter = 0
      clus.decode_block_size = 120
      index = faiss.IndexFlatL2(d)
      clus.train_encoded(codes, codec, index)
      new_centroids = faiss.vector_to_array(clus.centroids).reshape(
          -1, d
      )
  
      _, new_errs = index.search(xt2, 1)
  
      # It's the same operation, so should be bit-exact the same
      self.assertTrue(np.all(ref_centroids == new_centroids))
  
imports: from __future__ import absolute_import, division, print_function
  import numpy
  import faiss
  import unittest
  import array
  from common_faiss_tests import get_dataset_2
label_desc: Use image node_id 5 for calling the TestClustering obj's underlying member method code with example usage: obj.test_encoded() without return types