code: def construct_sparse_matrix(codes, K):
      n, M = codes.shape
      B = np.zeros((n, M * K), dtype=np.float32)
      for i in range(n):
          for j in range(M):
              code = codes[i, j]
              B[i, j * K + code] = 1
      return B
  
imports: import numpy
  import faiss
  import unittest
  from faiss.contrib import datasets
label_desc: Use image node_id 1 for calling a global function with example usage: construct_sparse_matrix(codes, K) and returns: B