code: def test_pq(self):
      d = 64
      n = 2000
      cs = 4
      np.random.seed(123)
      x = np.random.random(size=(n, d)).astype("float32")
      pq = faiss.ProductQuantizer(d, cs, 8)
      pq.train(x)
      codes = pq.compute_codes(x)
      x2 = pq.decode(codes)
      diff = ((x - x2) ** 2).sum()
  
      # print("diff=", diff)
      # diff= 4418.0562
      self.assertGreater(5000, diff)
  
      pq10 = faiss.ProductQuantizer(d, cs, 10)
      assert pq10.code_size == 5
      pq10.verbose = True
      pq10.cp.verbose = True
      pq10.train(x)
      codes = pq10.compute_codes(x)
  
      x10 = pq10.decode(codes)
      diff10 = ((x - x10) ** 2).sum()
      self.assertGreater(diff, diff10)
  
imports: from __future__ import absolute_import, division, print_function
  import numpy
  import faiss
  import unittest
label_desc: Use image node_id 1 for calling the TestProductQuantizer obj's underlying member method code with example usage: obj.test_pq() without return types