code: def regress_opt_beta(x, x_coded, Inn):
      (N, knn) = get_Inn_shape(Inn)
      d = x.shape[1]
  
      # construct the linear system to be solved
      X = np.zeros((d * N))
      Y = np.zeros((d * N, knn))
      for i in range(N):
          X[i * d : (i + 1) * d] = x[i, :]
          neighbor_table = get_neighbor_table(x_coded, Inn, i)
          Y[i * d : (i + 1) * d, :] = neighbor_table.transpose()
      beta_opt = np.linalg.lstsq(Y, X, rcond=0.01)[0]
      return beta_opt
  
file_path: faiss/benchs/link_and_code/neighbor_codec.py
imports: from __future__ import print_function
  import time
  import numpy
  import faiss
label_desc: Use image node_id 6 for calling a global function with example usage: regress_opt_beta(x, x_coded, Inn) and returns: beta_opt