code: def main(args):
      data = load_data(args.normalize, args.symmetry)
      log.info("preprocess finish")
      log.info("Train Examples: %s" % len(data["train_index"]))
      log.info("Val Examples: %s" % len(data["val_index"]))
      log.info("Test Examples: %s" % len(data["test_index"]))
      log.info("Num nodes %s" % data["graph"].num_nodes)
      log.info("Num edges %s" % data["graph"].num_edges)
      log.info("Average Degree %s" % np.mean(data["graph"].indegree()))
  
      place = fluid.CUDAPlace(0) if args.use_cuda else fluid.CPUPlace()
      train_program = fluid.Program()
      startup_program = fluid.Program()
      samples = []
      if args.samples_1 > 0:
          samples.append(args.samples_1)
      if args.samples_2 > 0:
          samples.append(args.samples_2)
  
      with fluid.program_guard(train_program, startup_program):
          feature, feature_init = paddle_helper.constant(
              "feat",
              dtype=data["feature"].dtype,
              value=data["feature"],
              hide_batch_size=False,
          )
  
          graph_wrapper = pgl.graph_wrapper.GraphWrapper(
              "sub_graph", node_feat=data["graph"].node_feat_info()
          )
  
          model_loss, model_acc = build_graph_model(
              graph_wrapper,
              num_class=data["num_class"],
              feature=feature,
              hidden_size=args.hidden_size,
              graphsage_type=args.graphsage_type,
              k_hop=len(samples),
          )
  
      test_program = train_program.clone(for_test=True)
  
      with fluid.program_guard(train_program, startup_program):
          adam = fluid.optimizer.Adam(learning_rate=args.lr)
          adam.minimize(model_loss)
  
      exe = fluid.Executor(place)
      exe.run(startup_program)
      feature_init(place)
  
      train_iter = reader.multiprocess_graph_reader(
          data["graph"],
          graph_wrapper,
          samples=samples,
          num_workers=args.sample_workers,
          batch_size=args.batch_size,
          with_parent_node_index=True,
          node_index=data["train_index"],
          node_label=data["train_label"],
      )
  
      val_iter = reader.multiprocess_graph_reader(
          data["graph"],
          graph_wrapper,
          samples=samples,
          num_workers=args.sample_workers,
          batch_size=args.batch_size,
          with_parent_node_index=True,
          node_index=data["val_index"],
          node_label=data["val_label"],
      )
  
      test_iter = reader.multiprocess_graph_reader(
          data["graph"],
          graph_wrapper,
          samples=samples,
          num_workers=args.sample_workers,
          batch_size=args.batch_size,
          with_parent_node_index=True,
          node_index=data["test_index"],
          node_label=data["test_label"],
      )
  
      for epoch in range(args.epoch):
          run_epoch(
              train_iter,
              program=train_program,
              exe=exe,
              prefix="train",
              model_loss=model_loss,
              model_acc=model_acc,
              epoch=epoch,
          )
  
          run_epoch(
              val_iter,
              program=test_program,
              exe=exe,
              prefix="val",
              model_loss=model_loss,
              model_acc=model_acc,
              log_per_step=10000,
              epoch=epoch,
          )
  
      run_epoch(
          test_iter,
          program=test_program,
          prefix="test",
          exe=exe,
          model_loss=model_loss,
          model_acc=model_acc,
          log_per_step=10000,
          epoch=epoch,
      )
  
file_path: PGL/legacy/examples/graphsage/train.py
imports: import os
  import argparse
  import time
  import numpy
  import scipy.sparse
  from sklearn.preprocessing import StandardScaler
  import pgl
  from pgl.utils.logger import log
  from pgl.utils import paddle_helper
  import paddle
  import paddle.fluid
  import reader
  from model import graphsage_mean, graphsage_meanpool, graphsage_maxpool, graphsage_lstm
label_desc: Use image node_id 4 for calling a global function with example usage: main(args) without return types