code: def train(
      args,
      model,
      graph,
      labels,
      train_idx,
      val_idx,
      test_idx,
      optimizer,
      evaluator,
  ):
      model.train()
  
      feat = graph.ndata["feat"]
  
      if args.use_labels:
          mask = torch.rand(train_idx.shape) < args.mask_rate
  
          train_labels_idx = train_idx[mask]
          train_pred_idx = train_idx[~mask]
  
          feat = add_labels(feat, labels, train_labels_idx)
      else:
          mask = torch.rand(train_idx.shape) < args.mask_rate
  
          train_pred_idx = train_idx[mask]
  
      optimizer.zero_grad()
      pred = model(graph, feat)
  
      if args.n_label_iters > 0:
          unlabel_idx = torch.cat([train_pred_idx, val_idx, test_idx])
          for _ in range(args.n_label_iters):
              pred = pred.detach()
              torch.cuda.empty_cache()
              feat[unlabel_idx, -n_classes:] = F.softmax(
                  pred[unlabel_idx], dim=-1
              )
              pred = model(graph, feat)
  
      loss = custom_loss_function(
          pred[train_pred_idx], labels[train_pred_idx]
      )
      loss.backward()
      optimizer.step()
  
      return evaluator(pred[train_idx], labels[train_idx]), loss.item()
  
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 8 for calling a global function with example usage: train(args, model, graph, labels, train_idx, val_idx, test_idx, optimizer, evaluator) and returns: evaluator,  loss