code: def main(args):
      """The main funciton for nodes classify task."""
      set_seed(args.seed)
      log.info(args)
      dataset = FlickrDataset(
          args.data_path, train_percentage=args.percent
      )
  
      train_steps = (
          len(dataset.train_index) // args.batch_size
      ) * args.epochs
      place = fluid.CUDAPlace(0) if args.use_cuda else fluid.CPUPlace()
      train_prog = fluid.Program()
      test_prog = fluid.Program()
      startup_prog = fluid.Program()
  
      with fluid.program_guard(train_prog, startup_prog):
          with fluid.unique_name.guard():
              train_model = node_classify_model(
                  dataset.graph,
                  dataset.num_groups,
                  embed_dim=args.embed_dim,
                  name="train",
              )
  
              lr = l.polynomial_decay(args.lr, train_steps, 0.0001)
              adam = fluid.optimizer.Adam(lr)
              adam.minimize(train_model["loss"])
      with fluid.program_guard(test_prog, startup_prog):
          with fluid.unique_name.guard():
              test_model = node_classify_model(
                  dataset.graph,
                  dataset.num_groups,
                  embed_dim=args.embed_dim,
                  name="test",
              )
      test_prog = test_prog.clone(for_test=True)
      exe = fluid.Executor(place)
      exe.run(startup_prog)
  
      train_model["pyreader"].decorate_tensor_provider(
          node_classify_generator(
              dataset.graph,
              dataset.train_index,
              batch_size=args.batch_size,
              epoch=args.epochs,
          )
      )
      test_model["pyreader"].decorate_tensor_provider(
          node_classify_generator(
              dataset.graph,
              dataset.test_index,
              batch_size=args.batch_size,
              epoch=1,
          )
      )
  
      def existed_params(var):
          """existed_params"""
          if not isinstance(var, fluid.framework.Parameter):
              return False
          return os.path.exists(os.path.join(args.ckpt_path, var.name))
  
      log.info("loading pretrained parameters from npy")
      load_param(args.ckpt_path, ["shared_w"])
  
      step = 0
      prev_time = time.time()
      train_model["pyreader"].start()
  
      final_macro_f1 = 0.0
      final_micro_f1 = 0.0
      while 1:
          try:
              (
                  train_loss_val,
                  train_probs_val,
                  train_labels_val,
                  train_topk_val,
              ) = exe.run(
                  train_prog,
                  fetch_list=[
                      train_model["loss"],
                      train_model["prob"],
                      train_model["labels"],
                      train_model["topk"],
                  ],
                  return_numpy=True,
              )
              train_macro_f1 = topk_f1_score(
                  train_labels_val,
                  train_probs_val,
                  train_topk_val,
                  "macro",
                  args.threshold,
              )
              train_micro_f1 = topk_f1_score(
                  train_labels_val,
                  train_probs_val,
                  train_topk_val,
                  "micro",
                  args.threshold,
              )
              step += 1
              log.info(
                  "Step %d " % step
                  + "Train Loss: %f " % train_loss_val
                  + "Train Macro F1: %f " % train_macro_f1
                  + "Train Micro F1: %f " % train_micro_f1
              )
          except fluid.core.EOFException:
              train_model["pyreader"].reset()
              break
  
          test_model["pyreader"].start()
          test_probs_vals, test_labels_vals, test_topk_vals = [], [], []
          while 1:
              try:
                  (
                      test_loss_val,
                      test_probs_val,
                      test_labels_val,
                      test_topk_val,
                  ) = exe.run(
                      test_prog,
                      fetch_list=[
                          test_model["loss"],
                          test_model["prob"],
                          test_model["labels"],
                          test_model["topk"],
                      ],
                      return_numpy=True,
                  )
                  test_probs_vals.append(
                      test_probs_val
                  ), test_labels_vals.append(test_labels_val)
                  test_topk_vals.append(test_topk_val)
              except fluid.core.EOFException:
                  test_model["pyreader"].reset()
                  test_probs_array = np.concatenate(test_probs_vals)
                  test_labels_array = np.concatenate(test_labels_vals)
                  test_topk_array = np.concatenate(test_topk_vals)
                  test_macro_f1 = topk_f1_score(
                      test_labels_array,
                      test_probs_array,
                      test_topk_array,
                      "macro",
                      args.threshold,
                  )
                  test_micro_f1 = topk_f1_score(
                      test_labels_array,
                      test_probs_array,
                      test_topk_array,
                      "micro",
                      args.threshold,
                  )
                  log.info(
                      "\t\tStep %d " % step
                      + "Test Loss: %f " % test_loss_val
                      + "Test Macro F1: %f " % test_macro_f1
                      + "Test Micro F1: %f " % test_micro_f1
                  )
                  final_macro_f1 = max(test_macro_f1, final_macro_f1)
                  final_micro_f1 = max(test_micro_f1, final_micro_f1)
                  break
  
      log.info(
          "\nFinal test Macro F1: %f " % final_macro_f1
          + "Final test Micro F1: %f " % final_micro_f1
      )
  
file_path: PGL/legacy/examples/line/multi_class.py
imports: import argparse
  import time
  import math
  import os
  import random
  import numpy
  import sklearn.metrics
  from sklearn.metrics import f1_score
  import pgl
  from pgl.utils import op
  import paddle.fluid
  import paddle.fluid.layers
  from pgl.utils.logger import log
  from data_loader import FlickrDataset
label_desc: Use image node_id 6 for calling a global function with example usage: main(args) and returns: os, False