code: def run(args, device, data):
      # Unpack data
      (
          train_nid,
          val_nid,
          test_nid,
          in_feats,
          labels,
          n_classes,
          nfeat,
          g,
          num_heads,
      ) = data
  
      # Create PyTorch DataLoader for constructing blocks
      sampler = dgl.dataloading.MultiLayerNeighborSampler(
          [int(fanout) for fanout in args.fan_out.split(",")]
      )
      dataloader = dgl.dataloading.DataLoader(
          g,
          train_nid,
          sampler,
          batch_size=args.batch_size,
          shuffle=True,
          drop_last=False,
          num_workers=args.num_workers,
      )
  
      # Define model and optimizer
      model = GAT(
          in_feats,
          args.num_hidden,
          n_classes,
          args.num_layers,
          num_heads,
          F.relu,
      )
      model = model.to(device)
      optimizer = optim.Adam(
          model.parameters(), lr=args.lr, weight_decay=args.wd
      )
  
      # Training loop
      avg = 0
      iter_tput = []
      best_eval_acc = 0
      best_test_acc = 0
      for epoch in range(args.num_epochs):
          tic = time.time()
  
          # Loop over the dataloader to sample the computation dependency graph as a list of
          # blocks.
          for step, (input_nodes, seeds, blocks) in enumerate(
              dataloader
          ):
              tic_step = time.time()
  
              # copy block to gpu
              blocks = [blk.to(device) for blk in blocks]
  
              # Load the input features as well as output labels
              batch_inputs, batch_labels = load_subtensor(
                  nfeat, labels, seeds, input_nodes
              )
  
              # Compute loss and prediction
              batch_pred = model(blocks, batch_inputs)
              loss = F.nll_loss(batch_pred, batch_labels)
              optimizer.zero_grad()
              loss.backward()
              optimizer.step()
  
              iter_tput.append(len(seeds) / (time.time() - tic_step))
              if step % args.log_every == 0:
                  acc = compute_acc(batch_pred, batch_labels)
                  gpu_mem_alloc = (
                      th.cuda.max_memory_allocated() / 1000000
                      if th.cuda.is_available()
                      else 0
                  )
                  print(
                      "Epoch {:05d} | Step {:05d} | Loss {:.4f} | Train Acc {:.4f} | Speed (samples/sec) {:.4f} | GPU {:.1f} MB".format(
                          epoch,
                          step,
                          loss.item(),
                          acc.item(),
                          np.mean(iter_tput[3:]),
                          gpu_mem_alloc,
                      )
                  )
  
          toc = time.time()
          print("Epoch Time(s): {:.4f}".format(toc - tic))
          if epoch >= 5:
              avg += toc - tic
          if epoch % args.eval_every == 0 and epoch != 0:
              eval_acc, test_acc, pred = evaluate(
                  model,
                  g,
                  nfeat,
                  labels,
                  val_nid,
                  test_nid,
                  num_heads,
                  device,
              )
              if args.save_pred:
                  np.savetxt(
                      args.save_pred + "%02d" % epoch,
                      pred.argmax(1).cpu().numpy(),
                      "%d",
                  )
              print("Eval Acc {:.4f}".format(eval_acc))
              if eval_acc > best_eval_acc:
                  best_eval_acc = eval_acc
                  best_test_acc = test_acc
              print(
                  "Best Eval Acc {:.4f} Test Acc {:.4f}".format(
                      best_eval_acc, best_test_acc
                  )
              )
  
      print("Avg epoch time: {}".format(avg / (epoch - 4)))
      return best_test_acc
  
file_path: dgl/examples/pytorch/ogb/ogbn-products/gat/main.py
imports: import argparse
  import time
  import dgl
  import dgl.nn.pytorch
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.optim
  import tqdm
  from ogb.nodeproppred import DglNodePropPredDataset
label_desc: Use image node_id 4 for calling a global function with example usage: run(args, device, data) and returns: best_test_acc