code: def run(
      args,
      graph,
      labels,
      train_idx,
      val_idx,
      test_idx,
      evaluator,
      n_running,
  ):
      evaluator_wrapper = lambda pred, labels: evaluator.eval(
          {
              "y_pred": pred.argmax(dim=-1, keepdim=True),
              "y_true": labels,
          }
      )["acc"]
  
      # define model and optimizer
      model = gen_model(args).to(device)
      optimizer = optim.RMSprop(
          model.parameters(), lr=args.lr, weight_decay=args.wd
      )
  
      # training loop
      total_time = 0
      best_val_acc, final_test_acc, best_val_loss = 0, 0, float("inf")
      final_pred = None
  
      accs, train_accs, val_accs, test_accs = [], [], [], []
      losses, train_losses, val_losses, test_losses = [], [], [], []
  
      for epoch in range(1, args.n_epochs + 1):
          tic = time.time()
  
          adjust_learning_rate(optimizer, args.lr, epoch)
  
          acc, loss = train(
              args,
              model,
              graph,
              labels,
              train_idx,
              val_idx,
              test_idx,
              optimizer,
              evaluator_wrapper,
          )
  
          (
              train_acc,
              val_acc,
              test_acc,
              train_loss,
              val_loss,
              test_loss,
              pred,
          ) = evaluate(
              args,
              model,
              graph,
              labels,
              train_idx,
              val_idx,
              test_idx,
              evaluator_wrapper,
          )
  
          toc = time.time()
          total_time += toc - tic
  
          if val_loss < best_val_loss:
              best_val_loss = val_loss
              best_val_acc = val_acc
              final_test_acc = test_acc
              final_pred = pred
  
          if epoch == args.n_epochs or epoch % args.log_every == 0:
              print(
                  f"Run: {n_running}/{args.n_runs}, Epoch: {epoch}/{args.n_epochs}, Average epoch time: {total_time / epoch:.2f}\n"
                  f"Loss: {loss:.4f}, Acc: {acc:.4f}\n"
                  f"Train/Val/Test loss: {train_loss:.4f}/{val_loss:.4f}/{test_loss:.4f}\n"
                  f"Train/Val/Test/Best val/Final test acc: {train_acc:.4f}/{val_acc:.4f}/{test_acc:.4f}/{best_val_acc:.4f}/{final_test_acc:.4f}"
              )
  
          for l, e in zip(
              [
                  accs,
                  train_accs,
                  val_accs,
                  test_accs,
                  losses,
                  train_losses,
                  val_losses,
                  test_losses,
              ],
              [
                  acc,
                  train_acc,
                  val_acc,
                  test_acc,
                  loss,
                  train_loss,
                  val_loss,
                  test_loss,
              ],
          ):
              l.append(e)
  
      print("*" * 50)
      print(
          f"Best val acc: {best_val_acc}, Final test acc: {final_test_acc}"
      )
      print("*" * 50)
  
      # plot learning curves
      if args.plot_curves:
          fig = plt.figure(figsize=(24, 24))
          ax = fig.gca()
          ax.set_xticks(np.arange(0, args.n_epochs, 100))
          ax.set_yticks(np.linspace(0, 1.0, 101))
          ax.tick_params(labeltop=True, labelright=True)
          for y, label in zip(
              [accs, train_accs, val_accs, test_accs],
              ["acc", "train acc", "val acc", "test acc"],
          ):
              plt.plot(
                  range(args.n_epochs), y, label=label, linewidth=1
              )
          ax.xaxis.set_major_locator(MultipleLocator(100))
          ax.xaxis.set_minor_locator(AutoMinorLocator(1))
          ax.yaxis.set_major_locator(MultipleLocator(0.01))
          ax.yaxis.set_minor_locator(AutoMinorLocator(2))
          plt.grid(which="major", color="red", linestyle="dotted")
          plt.grid(which="minor", color="orange", linestyle="dotted")
          plt.legend()
          plt.tight_layout()
          plt.savefig(f"gat_acc_{n_running}.png")
  
          fig = plt.figure(figsize=(24, 24))
          ax = fig.gca()
          ax.set_xticks(np.arange(0, args.n_epochs, 100))
          ax.tick_params(labeltop=True, labelright=True)
          for y, label in zip(
              [losses, train_losses, val_losses, test_losses],
              ["loss", "train loss", "val loss", "test loss"],
          ):
              plt.plot(
                  range(args.n_epochs), y, label=label, linewidth=1
              )
          ax.xaxis.set_major_locator(MultipleLocator(100))
          ax.xaxis.set_minor_locator(AutoMinorLocator(1))
          ax.yaxis.set_major_locator(MultipleLocator(0.1))
          ax.yaxis.set_minor_locator(AutoMinorLocator(5))
          plt.grid(which="major", color="red", linestyle="dotted")
          plt.grid(which="minor", color="orange", linestyle="dotted")
          plt.legend()
          plt.tight_layout()
          plt.savefig(f"gat_loss_{n_running}.png")
  
      if args.save_pred:
          os.makedirs("./output", exist_ok=True)
          torch.save(
              F.softmax(final_pred, dim=1), f"./output/{n_running}.pt"
          )
  
      return best_val_acc, final_test_acc
  
imports: import argparse
  import math
  import os
  import random
  import time
  import dgl
  import numpy
  import torch
  import torch.nn.functional
  import torch.optim
  from matplotlib import pyplot
  from matplotlib.ticker import AutoMinorLocator, MultipleLocator
  from models import GAT
  from ogb.nodeproppred import DglNodePropPredDataset, Evaluator
label_desc: Use image node_id 10 for calling a global function with example usage: run(args, graph, labels, train_idx, val_idx, test_idx, evaluator, n_running) and returns: best_val_acc,  final_test_acc