code: def main(args):
      """main"""
      place = fluid.CUDAPlace(0) if args.use_cuda else fluid.CPUPlace()
      exe = fluid.Executor(place)
  
      train_program = fluid.Program()
      startup_program = fluid.Program()
  
      with fluid.program_guard(train_program, startup_program):
          ret_dict = build_graph_model(args=args)
  
      val_program = train_program.clone(for_test=True)
      if args.phase == "train":
          with fluid.program_guard(train_program, startup_program):
              adam = fluid.optimizer.Adam(learning_rate=args.lr)
              adam.minimize(ret_dict.loss)
      # reset the place according to role of parameter server
      exe.run(startup_program)
  
      with open(args.data_path) as f:
          log.info("Begin Load Graph")
          src = []
          dst = []
          for idx, line in tqdm.tqdm(enumerate(f)):
              s, d = line.strip().split()
              src.append(s)
              dst.append(d)
              dst.append(s)
              src.append(d)
      src = np.array(src, dtype="int64").reshape(-1, 1)
      dst = np.array(dst, dtype="int64").reshape(-1, 1)
      edges = np.hstack([src, dst])
  
      log.info("Begin Build Index")
      ret_dict.graph = pgl.graph.Graph(
          num_nodes=args.num_nodes, edges=edges
      )
      ret_dict.graph.indegree()
      log.info("End Build Index")
  
      if args.phase == "train":
          # just the worker, load the sample
          data = load_pos_neg(args.data_path)
  
          feed_name_list = [var.name for var in ret_dict.feed_list]
          train_iter = reader.graph_reader(
              args.num_layers,
              ret_dict.graph_wrappers,
              batch_size=args.batch_size,
              data=data["train_data"],
              samples=args.samples,
              num_workers=args.sample_workers,
              feed_name_list=feed_name_list,
              use_pyreader=args.use_pyreader,
              graph=ret_dict.graph,
          )
  
          # get PyReader
          for epoch in range(args.epoch):
              epoch_start = time.time()
              try:
                  run_epoch(
                      train_iter,
                      program=train_program,
                      exe=exe,
                      prefix="train",
                      model_dict=ret_dict,
                      epoch=epoch,
                      batch_size=args.batch_size,
                      log_per_step=1,
                  )
                  epoch_end = time.time()
                  print(
                      "Epoch: {0}, Train total expend: {1} ".format(
                          epoch, epoch_end - epoch_start
                      )
                  )
              except Exception as e:
                  log.info("Run Epoch Error %s" % e)
              fluid.io.save_params(
                  exe,
                  dirname=args.checkpoint + "_%s" % (epoch + 1),
                  main_program=train_program,
              )
  
              log.info("EPOCH END")
  
          log.info("RUN FINISH")
      elif args.phase == "predict":
          fluid.io.load_params(
              exe,
              dirname=args.checkpoint + "_%s" % args.epoch,
              main_program=val_program,
          )
          test_src = np.arange(0, args.num_nodes, dtype="int64")
          feed_name_list = [var.name for var in ret_dict.feed_list]
          predict_iter = reader.graph_reader(
              args.num_layers,
              ret_dict.graph_wrappers,
              batch_size=args.batch_size,
              data=(test_src, test_src, test_src),
              samples=args.samples,
              num_workers=args.sample_workers,
              feed_name_list=feed_name_list,
              use_pyreader=args.use_pyreader,
              graph=ret_dict.graph,
              predict=True,
          )
          run_predict_epoch(
              predict_iter,
              program=val_program,
              exe=exe,
              prefix="predict",
              hidden_size=args.hidden_size,
              model_dict=ret_dict,
              num_nodes=args.num_nodes,
              log_per_step=100,
          )
          log.info("EPOCH END")
  
imports: import argparse
  import time
  import glob
  import os
  import numpy
  import pgl
  from pgl.utils.logger import log
  from pgl.utils import paddle_helper
  import paddle
  import paddle.fluid
  import tqdm
  import reader
  import model
label_desc: Use image node_id 7 for calling a global function with example usage: main(args) without return types