code: def assign_beta_2(beta_centroids, x, rfn, Inn):
      _, _, sq = Inn
      if rfn.k == 1:
          return np.zeros(x.shape[0], dtype=int)
      # add dummy dimensions to beta_centroids and x
      all_beta_centroids = np.zeros(
          (rfn.nsq, rfn.k, rfn.M + 1), dtype="float32"
      )
      all_beta_centroids[sq] = beta_centroids
      all_x = np.zeros((len(x), rfn.d), dtype="float32")
      all_x[:, sq * rfn.dsub : (sq + 1) * rfn.dsub] = x
      rfn.codes.clear()
      rfn.ntotal = 0
      faiss.copy_array_to_vector(
          all_beta_centroids.ravel(), rfn.codebook
      )
      rfn.add_codes(len(x), faiss.swig_ptr(all_x))
      codes = faiss.vector_to_array(rfn.codes)
      codes = codes.reshape(-1, rfn.nsq)
      return codes[:, sq]
  
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 10 for calling a global function with example usage: assign_beta_2(beta_centroids, x, rfn, Inn) and returns: codes, np