code: def test_icm_encode_step(self):
      d = 16
      n = 500
      M = 4
      nbits = 6
      K = 1 << nbits
  
      rs = np.random.RandomState(123)
  
      # randomly generate codes and unary terms
      codes = rs.randint(0, K, (n, M)).astype(np.int32)
      new_codes = codes.copy()
      unaries = rs.rand(M, n, K).astype(np.float32)
  
      # binary terms should be symmetric, because binary terms
      #  represent cached dot products between the code C1 in codebook M1
      #  and the code C2 in codebook M2.
      # so, binaries[M1, M2, C1, C2] == binaries[M2, M1, C2, C1]
      #
      # generate binary terms in a standard way that provides
      #  the needed symmetry
      codebooks = rs.rand(M, K, d).astype(np.float32)
      binaries = compute_binary_terms_ref(codebooks)
      binaries = np.ascontiguousarray(binaries)
  
      # do icm encoding given binary and unary terms
      lsq = faiss.LocalSearchQuantizer(d, M, nbits)
      lsq.icm_encode_step(
          sp(new_codes), sp(unaries), sp(binaries), n, 1
      )
  
      # do icm encoding given binary and unary terms in Python
      ref_codes = icm_encode_step_ref(unaries, binaries, codes)
      np.testing.assert_array_equal(new_codes, ref_codes)
  
imports: import numpy
  import faiss
  import unittest
  from faiss.contrib import datasets
label_desc: Use image node_id 6 for calling the TestComponents obj's underlying member method code with example usage: obj.test_icm_encode_step() without return types