code: def link_predict_generator(
      pos_edges, neg_edges, batch_size=512, epoch=2000, shuffle=True
  ):
      all_edges = []
      for u, v in pos_edges:
          all_edges.append([u, v, 1])
      for u, v in neg_edges:
          all_edges.append([u, v, 0])
      all_edges = np.array(all_edges, np.int64)
  
      def batch_edges_generator(shuffle=shuffle):
          perm = np.arange(len(all_edges), dtype=np.int64)
          if shuffle:
              np.random.shuffle(perm)
          start = 0
          while start < len(all_edges):
              yield all_edges[perm[start : start + batch_size]]
              start += batch_size
  
      def wrapper():
          for _ in range(epoch):
              for batch_edges in batch_edges_generator():
                  yield batch_edges.T[0:1].T, batch_edges.T[
                      1:2
                  ].T, batch_edges.T[2:3].T
  
      return wrapper
  
file_path: PGL/legacy/examples/deepwalk/link_predict.py
imports: import argparse
  import time
  import math
  import os
  import numpy
  from sklearn import metrics
  import pgl
  from pgl import data_loader
  from pgl.utils import op
  from pgl.utils.logger import log
  import paddle.fluid
  import paddle.fluid.layers
label_desc: Use image node_id 4 for calling a global function with example usage: link_predict_generator(pos_edges, neg_edges, batch_size, epoch, shuffle) and returns: wrapper