code: def do_test(self, key1, key2):
      d = 96
      nb = 1000
      nq = 0
      nt = 2000
  
      xt, x, _ = get_dataset_2(d, nt, nb, nq)
  
      codec_ref = faiss.index_factory(d, key1)
      codec_ref.train(xt)
  
      code_ref = codec_ref.sa_encode(x)
      x_recons_ref = codec_ref.sa_decode(code_ref)
  
      codec_new = faiss.index_factory(d, key2)
      codec_new.pq = codec_ref.pq
  
      # replace quantizer, avoiding mem leak
      oldq = codec_new.q1.quantizer
      oldq.this.own()
      codec_new.q1.own_fields = False
      codec_new.q1.quantizer = codec_ref.quantizer
      codec_new.is_trained = True
  
      code_new = codec_new.sa_encode(x)
      x_recons_new = codec_new.sa_decode(code_new)
  
      self.assertTrue(np.all(code_new == code_ref))
      self.assertTrue(np.all(x_recons_new == x_recons_ref))
  
      codec_new_2 = faiss.deserialize_index(
          faiss.serialize_index(codec_new)
      )
  
      code_new = codec_new_2.sa_encode(x)
      x_recons_new = codec_new_2.sa_decode(code_new)
  
      self.assertTrue(np.all(code_new == code_ref))
      self.assertTrue(np.all(x_recons_new == x_recons_ref))
  
imports: from __future__ import print_function
  import numpy
  import unittest
  import faiss
  from common_faiss_tests import get_dataset_2
  from faiss.contrib.datasets import SyntheticDataset
  from faiss.contrib.inspect_tools import get_additive_quantizer_codebooks
label_desc: Use image node_id 1 for calling the TestIndexEquiv obj's underlying member method code with example usage: obj.do_test(key1, key2) without return types