code: def distribute_weights(weights, nbin):
      """assign a set of weights to a smaller set of bins to balance them"""
      nw = weights.size
      o = weights.argsort()
      bins = np.zeros(nbin)
      assign = np.ones(nw, dtype=int)
      for i in o[::-1]:
          b = bins.argmin()
          assign[i] = b
          bins[b] += weights[i]
      return bins, assign
  
imports: import time
  from faiss.contrib import rpc
  import combined_index
  import argparse
  from multiprocessing.pool import ThreadPool
  import faiss
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: distribute_weights(weights, nbin) and returns: bins,  assign