code: def main(args):
      # Step 1: Prepare graph data and retrieve train/validation/test index ============================= #
      # Load from DGL dataset
      if args.dataset == "Cora":
          dataset = CoraGraphDataset()
      elif args.dataset == "Citeseer":
          dataset = CiteseerGraphDataset()
      elif args.dataset == "Pubmed":
          dataset = PubmedGraphDataset()
      else:
          raise ValueError(
              "Dataset {} is invalid.".format(args.dataset)
          )
  
      graph = dataset[0]
      graph = graph.add_self_loop()
  
      # check cuda
      if args.gpu >= 0 and torch.cuda.is_available():
          device = "cuda:{}".format(args.gpu)
      else:
          device = "cpu"
  
      # retrieve the number of classes
      n_classes = dataset.num_classes
  
      # retrieve labels of ground truth
      labels = graph.ndata.pop("label").to(device).long()
  
      # Extract node features
      feats = graph.ndata.pop("feat").to(device)
      n_features = feats.shape[-1]
  
      # retrieve masks for train/validation/test
      train_mask = graph.ndata.pop("train_mask")
      val_mask = graph.ndata.pop("val_mask")
      test_mask = graph.ndata.pop("test_mask")
  
      train_idx = (
          torch.nonzero(train_mask, as_tuple=False).squeeze().to(device)
      )
      val_idx = (
          torch.nonzero(val_mask, as_tuple=False).squeeze().to(device)
      )
      test_idx = (
          torch.nonzero(test_mask, as_tuple=False).squeeze().to(device)
      )
  
      graph = graph.to(device)
  
      # Step 2: Create model =================================================================== #
      model = DAGNN(
          k=args.k,
          in_dim=n_features,
          hid_dim=args.hid_dim,
          out_dim=n_classes,
          dropout=args.dropout,
      )
      model = model.to(device)
  
      # Step 3: Create training components ===================================================== #
      loss_fn = F.cross_entropy
      opt = torch.optim.Adam(
          model.parameters(), lr=args.lr, weight_decay=args.lamb
      )
  
      # Step 4: training epochs =============================================================== #
      loss = float("inf")
      best_acc = 0
      no_improvement = 0
      epochs = trange(args.epochs, desc="Accuracy & Loss")
  
      for _ in epochs:
          model.train()
  
          logits = model(graph, feats)
  
          # compute loss
          train_loss = loss_fn(logits[train_idx], labels[train_idx])
  
          # backward
          opt.zero_grad()
          train_loss.backward()
          opt.step()
  
          (
              train_loss,
              train_acc,
              valid_loss,
              valid_acc,
              test_loss,
              test_acc,
          ) = evaluate(
              model,
              graph,
              feats,
              labels,
              (train_idx, val_idx, test_idx),
          )
  
          # Print out performance
          epochs.set_description(
              "Train Acc {:.4f} | Train Loss {:.4f} | Val Acc {:.4f} | Val loss {:.4f}".format(
                  train_acc,
                  train_loss.item(),
                  valid_acc,
                  valid_loss.item(),
              )
          )
  
          if valid_loss > loss:
              no_improvement += 1
              if no_improvement == args.early_stopping:
                  print("Early stop.")
                  break
          else:
              no_improvement = 0
              loss = valid_loss
              best_acc = test_acc
  
      print("Test Acc {:.4f}".format(best_acc))
      return best_acc
  
imports: import argparse
  import dgl.function
  import numpy
  import torch
  from dgl.data import CiteseerGraphDataset, CoraGraphDataset, PubmedGraphDataset
  from torch import nn
  from torch.nn import functional, Parameter
  from tqdm import trange
  from utils import evaluate, generate_random_seeds, set_random_state
label_desc: Use image node_id 1 for calling a global function with example usage: main(args) and returns: best_acc