code: def cross_knn(X, Y, k=1):
      """return the k-nearest-neighbours graph of from X to Y
  
      Parameters
      ----------
      X, Y arrays of shape (n1, p) and (n2, p)
      where p = common dimension of the features
      eps=1, float: the neighbourhood size considered
  
      Returns
      -------
      BipartiteGraph instance
  
      Notes
      -----
      For the sake of speed it is advised to give PCA-transformed matrices X and
      Y.
      """
      from scipy.sparse import coo_matrix
  
      check_feature_matrices(X, Y)
      try:
          k = int(k)
      except:
          "k cannot be cast to an int"
      if np.isnan(k):
          raise ValueError("k is nan")
      if np.isinf(k):
          raise ValueError("k is inf")
      k = min(k, Y.shape[0] - 1)
  
      ij = np.zeros((0, 2))
      data = np.zeros(0)
      for i, x in enumerate(X):
          dist = np.sum((Y - x) ** 2, 1)
          idx = np.argsort(dist)[:k]
          data = np.hstack((data, dist[idx]))
          ij = np.vstack(
              (
                  ij,
                  np.hstack(
                      (i * np.ones((k, 1)), np.reshape(idx, (k, 1)))
                  ),
              )
          )
  
      data = np.maximum(data, 1.0e-15)
      adj = coo_matrix((data, ij.T), shape=(X.shape[0], Y.shape[0]))
      return bipartite_graph_from_coo_matrix(adj)
  
file_path: nipy/nipy/algorithms/graph/bipartite_graph.py
imports: import numpy
label_desc: Use image node_id 5 for calling a global function with example usage: cross_knn(X, Y, k) and returns: bipartite_graph_from_coo_matrix