code: def test_shards_ivf_train_add(self):
      ds = SyntheticDataset(32, 1000, 600, 20)
      quantizer = faiss.IndexFlatL2(ds.d)
      sharded_index = faiss.IndexShardsIVF(quantizer, 40, False, False)
  
      for _ in range(3):
          sharded_index.add_shard(
              faiss.index_factory(ds.d, "IVF40,Flat")
          )
  
      sharded_index.train(ds.get_train())
      sharded_index.add(ds.get_database())
      Dnew, Inew = sharded_index.search(ds.get_queries(), 10)
  
      index_ref = faiss.IndexIVFFlat(
          quantizer, ds.d, sharded_index.nlist
      )
      index_ref.train(ds.get_train())
      index_ref.add(ds.get_database())
      Dref, Iref = index_ref.search(ds.get_queries(), 10)
      np.testing.assert_equal(Inew, Iref)
      np.testing.assert_allclose(Dnew, Dref)
  
      # mess around with the quantizer's centroids
      centroids = quantizer.reconstruct_n()
      centroids = centroids[::-1].copy()
      quantizer.reset()
      quantizer.add(centroids)
  
      D2, I2 = sharded_index.search(ds.get_queries(), 10)
      self.assertFalse(np.all(I2 == Inew))
  
file_path: faiss/tests/test_meta_index.py
imports: import os
  import numpy
  import faiss
  import unittest
  from common_faiss_tests import Randu10k
  from faiss.contrib.datasets import SyntheticDataset
label_desc: Use image node_id 3 for calling the Shards obj's underlying member method code with example usage: obj.test_shards_ivf_train_add() without return types