code: def getknn(sc, x, y, k=10):
      sidx = np.argpartition(sc, -k, axis=1)[:, -k:]
      ytopk = y[sidx.flatten(), :]
      ytopk = ytopk.reshape(sidx.shape[0], sidx.shape[1], y.shape[1])
      f = np.sum(sc[np.arange(sc.shape[0])[:, None], sidx])
      df = np.dot(ytopk.sum(1).T, x)
      return f / k, df / k
  
file_path: fastText/alignment/unsup_multialign.py
imports: import io, os, ot, argparse, random
  import numpy
  from utils import *
label_desc: Use image node_id 1 for calling a global function with example usage: getknn(sc, x, y, k) and returns: unknown,  unknown