code: def main(args):
      # A dataset with 80 samples, each graph is
      # of size [10, 20]
      dataset = MiniGCDataset(80, 10, 20)
      graph, label = dataset[0]
  
      # Create training and test sets.
      trainset = MiniGCDataset(320, 10, 20)
      testset = MiniGCDataset(80, 10, 20)
      # Use PyTorch's DataLoader and the collate function
      # defined before.
      data_loader = DataLoader(
          trainset,
          batch_size=args.batch_size,
          shuffle=True,
          collate_fn=collate,
      )
  
      num_feats = 1
      num_classes = 8
      # Create model
      model = GNNClassifier(
          args.num_layers,
          num_feats,
          args.num_hidden,
          num_classes,
          args.num_heads,
          args.num_out_heads,
          direction_option=args.direction_option,
          graph_pooling=args.graph_pooling,
          feat_drop=args.in_drop,
          attn_drop=args.attn_drop,
          negative_slope=args.negative_slope,
          residual=args.residual,
          activation=F.elu,
      )
  
      loss_func = nn.CrossEntropyLoss()
      optimizer = optim.Adam(model.parameters(), lr=args.lr)
      model.train()
  
      epoch_losses = []
      for epoch in range(args.epochs):
          epoch_loss = 0
          for bg, label in data_loader:
              bg = prepare_batched_graph(bg)
              prediction = model(bg)
              loss = loss_func(prediction, label)
              optimizer.zero_grad()
              loss.backward()
              optimizer.step()
              epoch_loss += loss.detach().item()
  
          epoch_loss /= len(data_loader)
          print("Epoch {}, loss {:.4f}".format(epoch, epoch_loss))
          epoch_losses.append(epoch_loss)
  
      ###############################################################################
      # The learning curve of a run is presented below.
  
      # plt.title('cross entropy averaged over minibatches')
      # plt.plot(epoch_losses)
      # plt.show()
  
      ###############################################################################
      # The trained model is evaluated on the test set created. To deploy
      # the tutorial, restrict the running time to get a higher
      # accuracy (:math:`80` % ~ :math:`90` %) than the ones printed below.
  
      model.eval()
      # Convert a list of tuples to two lists
      test_X, test_Y = map(list, zip(*testset))
      test_bg = prepare_batched_graph(dgl.batch(test_X))
      test_Y = torch.tensor(test_Y).float().view(-1, 1)
      probs_Y = torch.softmax(model(test_bg), 1)
      sampled_Y = torch.multinomial(probs_Y, 1)
      argmax_Y = torch.max(probs_Y, 1)[1].view(-1, 1)
      print(
          "Accuracy of sampled predictions on the test set: {:.4f}%".format(
              (test_Y == sampled_Y.float()).sum().item()
              / len(test_Y)
              * 100
          )
      )
      print(
          "Accuracy of argmax predictions on the test set: {:4f}%".format(
              (test_Y == argmax_Y.float()).sum().item()
              / len(test_Y)
              * 100
          )
      )
  
file_path: graph4nlp/graph4nlp/pytorch/test/graph_classification/run_graph_classification.py
imports: import argparse
  import dgl
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.optim
  from dgl.data import MiniGCDataset
  from torch.utils.data import DataLoader
  from ...data.data import from_dgl, to_batch
  from ...modules.graph_embedding_learning.gat import GAT
  from ...modules.prediction.classification.graph_classification import FeedForwardNN
label_desc: Use image node_id 3 for calling a global function with example usage: main(args) without return types