code: def update_codebooks_ref(x, codes, K, lambd):
      n, d = x.shape
      M = codes.shape[1]
  
      B = construct_sparse_matrix(codes, K)
      reg = np.identity(M * K) * float(lambd)
      reg = reg.astype(np.float32)
  
      # C = (B'B + lambd * I)^(-1)B'X
      bb = np.linalg.inv(B.T @ B + reg)
      C = bb @ B.T @ x
      C = C.reshape(M, K, d)
  
      return C
  
imports: import numpy
  import faiss
  import unittest
  from faiss.contrib import datasets
label_desc: Use image node_id 2 for calling a global function with example usage: update_codebooks_ref(x, codes, K, lambd) and returns: C