code: def test_compute_unary_terms(self):
      d = 16
      n = 500
      M = 4
      nbits = 6
      K = 1 << nbits
  
      rs = np.random.RandomState(123)
      x = rs.rand(n, d).astype(np.float32)
      unaries = np.zeros((M, n, K)).astype(np.float32)
  
      lsq = faiss.LocalSearchQuantizer(d, M, nbits)
      lsq.train(x)  # just for allocating memory for codebooks
  
      lsq.compute_unary_terms(sp(x), sp(unaries), n)
  
      codebooks = faiss.vector_float_to_array(lsq.codebooks)
      codebooks = codebooks.reshape(M, K, d).copy()
      ref_unaries = compute_unary_terms_ref(codebooks, x)
  
      np.testing.assert_allclose(unaries, ref_unaries, atol=1e-4)
  
imports: import numpy
  import faiss
  import unittest
  from faiss.contrib import datasets
label_desc: Use image node_id 5 for calling the TestComponents obj's underlying member method code with example usage: obj.test_compute_unary_terms() without return types