code: def main(args):
      # set up seeds, args.seed supported
      mx.random.seed(0)
      np.random.seed(seed=0)
  
      if args.device >= 0:
          args.device = mx.gpu(args.device)
      else:
          args.device = mx.cpu()
  
      dataset = GINDataset(args.dataset, not args.learn_eps)
  
      trainloader, validloader = GraphDataLoader(
          dataset,
          batch_size=args.batch_size,
          collate_fn=collate,
          seed=args.seed,
          shuffle=True,
          split_name="fold10",
          fold_idx=args.fold_idx,
      ).train_valid_loader()
      # or split_name='rand', split_ratio=0.7
  
      model = GIN(
          args.num_layers,
          args.num_mlp_layers,
          dataset.dim_nfeats,
          args.hidden_dim,
          dataset.gclasses,
          args.final_dropout,
          args.learn_eps,
          args.graph_pooling_type,
          args.neighbor_pooling_type,
      )
      model.initialize(ctx=args.device)
  
      criterion = gluon.loss.SoftmaxCELoss()
  
      print(model.collect_params())
      lr_scheduler = mx.lr_scheduler.FactorScheduler(50, 0.5)
      trainer = gluon.Trainer(
          model.collect_params(), "adam", {"lr_scheduler": lr_scheduler}
      )
  
      # it's not cost-effective to hanle the cursor and init 0
      # https://stackoverflow.com/a/23121189
      tbar = tqdm(
          range(args.epochs),
          unit="epoch",
          position=3,
          ncols=0,
          file=sys.stdout,
      )
      vbar = tqdm(
          range(args.epochs),
          unit="epoch",
          position=4,
          ncols=0,
          file=sys.stdout,
      )
      lrbar = tqdm(
          range(args.epochs),
          unit="epoch",
          position=5,
          ncols=0,
          file=sys.stdout,
      )
  
      for epoch, _, _ in zip(tbar, vbar, lrbar):
          train(args, model, trainloader, trainer, criterion, epoch)
  
          train_loss, train_acc = eval_net(
              args, model, trainloader, criterion
          )
          tbar.set_description(
              "train set - average loss: {:.4f}, accuracy: {:.0f}%".format(
                  train_loss, 100.0 * train_acc
              )
          )
  
          valid_loss, valid_acc = eval_net(
              args, model, validloader, criterion
          )
          vbar.set_description(
              "valid set - average loss: {:.4f}, accuracy: {:.0f}%".format(
                  valid_loss, 100.0 * valid_acc
              )
          )
  
          if not args.filename == "":
              with open(args.filename, "a") as f:
                  f.write(
                      "%s %s %s %s"
                      % (
                          args.dataset,
                          args.learn_eps,
                          args.neighbor_pooling_type,
                          args.graph_pooling_type,
                      )
                  )
                  f.write("\n")
                  f.write(
                      "%f %f %f %f"
                      % (train_loss, train_acc, valid_loss, valid_acc)
                  )
                  f.write("\n")
  
          lrbar.set_description(
              "Learning eps with learn_eps={}: {}".format(
                  args.learn_eps,
                  [
                      layer.eps.data(args.device).asscalar()
                      for layer in model.ginlayers
                  ],
              )
          )
  
      tbar.close()
      vbar.close()
      lrbar.close()
  
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 3 for calling a global function with example usage: main(args) without return types