code: def train(args, net, trainloader, trainer, criterion, epoch):
      running_loss = 0
      total_iters = len(trainloader)
      # setup the offset to avoid the overlap with mouse cursor
      bar = tqdm(
          range(total_iters), unit="batch", position=2, file=sys.stdout
      )
  
      for pos, (graphs, labels) in zip(bar, trainloader):
          # batch graphs will be shipped to device in forward part of model
          labels = labels.as_in_context(args.device)
          feat = graphs.ndata["attr"].as_in_context(args.device)
  
          with mx.autograd.record():
              graphs = graphs.to(args.device)
              outputs = net(graphs, feat)
              loss = criterion(outputs, labels)
              loss = loss.sum() / len(labels)
  
          running_loss += loss.asscalar()
  
          # backprop
          loss.backward()
          trainer.step(batch_size=1)
  
          # report
          bar.set_description("epoch-{}".format(epoch))
      bar.close()
      # the final batch will be aligned
      running_loss = running_loss / total_iters
  
      return running_loss
  
file_path: dgl/examples/mxnet/gin/main.py
imports: import sys
  from parser import Parser
  import mxnet
  import numpy
  from dataloader import collate, GraphDataLoader
  from dgl.data.gindt import GINDataset
  from gin import GIN
  from mxnet import gluon, nd
  from mxnet.gluon import nn
  from tqdm import tqdm
label_desc: Use image node_id 1 for calling a global function with example usage: train(args, net, trainloader, trainer, criterion, epoch) and returns: running_loss