code: def compute_binary_terms_ref(codebooks):
      M, K, d = codebooks.shape
  
      codebooks_t = np.swapaxes(codebooks, 1, 2)  # [M, d, K]
      binaries = 2 * codebooks.dot(codebooks_t)  # [M, K, M, K]
      binaries = np.swapaxes(binaries, 1, 2)  # [M, M, K, K]
  
      return binaries
  
imports: import numpy
  import faiss
  import unittest
  from faiss.contrib import datasets
label_desc: Use image node_id 3 for calling a global function with example usage: compute_binary_terms_ref(codebooks) and returns: binaries