code: def assign_beta(beta_centroids, x, x_coded, Inn, verbose=True):
      if type(Inn) == tuple:
          return assign_beta_2(beta_centroids, x, x_coded, Inn)
      (N, knn) = Inn.shape
      x_ibeta = np.zeros((N), dtype="int32")
      t0 = time.time()
      for i in range(N):
          NNi = x_coded[Inn[i, :]]
          # Consider all possible betas for the encoding and compute the
          # encoding error
          x_reg_all = np.dot(beta_centroids, NNi)
          err = ((x_reg_all - x[i, :]) ** 2).sum(axis=1)
          x_ibeta[i] = err.argmin()
          if verbose:
              if i % (N / 10) == 0:
                  print(
                      "[%d:%d]  %6.3fs"
                      % (i, i + N / 10, time.time() - t0)
                  )
      return x_ibeta
  
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 7 for calling a global function with example usage: assign_beta(beta_centroids, x, x_coded, Inn, verbose) and returns: x_ibeta, assign_beta_2