code: def train_loop(
      parser,
      start_program,
      main_program,
      test_program,
      model,
      graph,
      label,
      split_idx,
      exe,
      run_id,
      wf=None,
  ):
      # build up training program
      exe.run(start_program)
  
      max_acc = 0  # best test_acc
      max_step = 0  # step for best test_acc
      max_val_acc = 0  # best val_acc
      max_cor_acc = 0  # test_acc for best val_acc
      max_cor_step = 0  # step for best val_acc
  
      graph.node_feat["label"] = label
      graph.node_feat["nid"] = np.arange(0, graph.num_nodes)
  
      def train_batch_func(subgraph):
          if parser.use_label_e:
              train_idx = copy.deepcopy(split_idx["train"])
              np.random.shuffle(train_idx[: int(50125)])
  
              label_idx = train_idx[: int(50125 * parser.label_rate)]
              unlabel_idx = train_idx[int(50125 * parser.label_rate) :]
  
              label_idx_total = set(label_idx)
              unlabel_idx_total = set(unlabel_idx)
  
              fd = model.gw.to_feed(subgraph)
              fd.update(
                  model.gw_sample.to_feed(sample_subgraph(subgraph))
              )
              sub_idx = set(subgraph.node_feat["nid"])
  
              train_idx_temp = label_idx_total & sub_idx
              label_idx = subgraph.reindex_from_parrent_nodes(
                  list(train_idx_temp)
              )
  
              train_idx_temp = unlabel_idx_total & sub_idx
              unlabel_idx = subgraph.reindex_from_parrent_nodes(
                  list(train_idx_temp)
              )
  
              fd["label"] = subgraph.node_feat["label"]
              fd["label_idx"] = label_idx
              fd["train_idx"] = unlabel_idx
          else:
              fd = model.gw.to_feed(subgraph)
              fd.update(
                  model.gw_sample.to_feed(sample_subgraph(subgraph))
              )
              train_idx_temp = set(split_idx["train"]) & set(
                  subgraph.node_feat["nid"]
              )
              train_idx_temp = subgraph.reindex_from_parrent_nodes(
                  list(train_idx_temp)
              )
              fd["label"] = subgraph.node_feat["label"]
              fd["train_idx"] = train_idx_temp
          return fd
  
      eval_partition = random_partition(
          num_clusters=parser.eval_partition, graph=graph, shuffle=False
      )
      train_partition = RandomPartition(
          batch_func=train_batch_func,
          graph=graph,
          num_cluster=parser.train_partition,
          epoch=parser.epochs,
          shuffle=True,
      )
  
      def eval_func(subgraph):
          fd = model.gw.to_feed(subgraph)
          fd.update(model.gw_sample.to_feed(sample_subgraph(subgraph)))
  
          if parser.use_label_e:
              fd["label"] = subgraph.node_feat["label"]
              train_idx_temp = set(split_idx["train"]) & set(
                  subgraph.node_feat["nid"]
              )
              train_idx_temp = subgraph.reindex_from_parrent_nodes(
                  list(train_idx_temp)
              )
              fd["label_idx"] = train_idx_temp
          return fd
  
      eval_partition = [
          (subgraph, eval_func(subgraph)) for subgraph in eval_partition
      ]
  
      epoch_id = 0
      batch_id = 0
  
      result = eval_test(
          parser,
          test_program,
          model,
          exe,
          graph,
          label,
          split_idx,
          eval_partition,
      )
  
      for feed_dict in tqdm(train_partition.generator()):
          # start training
          batch_id += 1
  
          loss = exe.run(
              main_program, feed=feed_dict, fetch_list=[model.avg_cost]
          )
          loss = loss[0]
  
          # eval result
          if batch_id % parser.train_partition == 0:
              epoch_id += 1
  
          if batch_id % 500 == 0:
              result = eval_test(
                  parser,
                  test_program,
                  model,
                  exe,
                  graph,
                  label,
                  split_idx,
                  eval_partition,
              )
              train_acc, valid_acc, test_acc = result
  
              max_acc = max(test_acc, max_acc)
              if max_acc == test_acc:
                  max_step = epoch_id
              max_val_acc = max(valid_acc, max_val_acc)
              if max_val_acc == valid_acc:
                  max_cor_acc = test_acc
                  max_cor_step = epoch_id
              max_acc = max(result[2], max_acc)
              if max_acc == result[2]:
                  max_step = epoch_id
              result_t = (
                  f"Run: {run_id:02d}, "
                  f"Epoch: {epoch_id:02d}, "
                  f"Train: {100 * train_acc:.2f}%, "
                  f"Valid: {100 * valid_acc:.2f}%, "
                  f"Test: {100 * test_acc:.2f}% \n"
                  f"max_Test: {100 * max_acc:.2f}%, "
                  f"max_step: {max_step}\n"
                  f"max_val: {100 * max_val_acc:.2f}%, "
                  f"max_val_Test: {100 * max_cor_acc:.2f}%, "
                  f"max_val_step: {max_cor_step}\n"
              )
              print(result_t)
              wf.write(result_t)
              wf.write("\n")
              wf.flush()
      return max_cor_acc
  
imports: import math
  import math
  import ssl
  from sklearn.metrics import roc_auc_score
  import torch
  import paddle
  import pgl
  import numpy
  import paddle.fluid
  import paddle.fluid.layers
  from pgl.contrib.ogb.nodeproppred.dataset_pgl import PglNodePropPredDataset
  import time
  import copy
  from ogb.nodeproppred import Evaluator
  import pickle
  from model import Proteins_baseline_model, Proteins_label_embedding_model
  from partition import RandomPartition
  from cross_edge_feat import cross_edge_feat
  from dataset.random_partition_dataset import RandomPartition
  import os
  import argparse
  from tqdm import tqdm
label_desc: Use image node_id 6 for calling a global function with example usage: train_loop(parser, start_program, main_program, test_program, model, graph, label, split_idx, exe, run_id, wf) and returns: max_cor_acc, fd, fd