code: def train(dataset, params):
      trainset, valset, testset = (
          dataset.train,
          dataset.val,
          dataset.test,
      )
      device = params.device
  
      print("Training Graphs: ", len(trainset))
      print("Validation Graphs: ", len(valset))
      print("Test Graphs: ", len(testset))
  
      model = DGNNet()
      model = model.to(device)
  
      # view model parameters
      total_param = 0
      print("MODEL DETAILS:\n")
      for param in model.parameters():
          total_param += np.prod(list(param.data.size()))
      print("DGN Total parameters:", total_param)
  
      optimizer = optim.Adam(
          model.parameters(), lr=0.0008, weight_decay=1e-5
      )
      scheduler = optim.lr_scheduler.ReduceLROnPlateau(
          optimizer, mode="min", factor=0.8, patience=8, verbose=True
      )
  
      epoch_train_losses, epoch_val_losses = [], []
      epoch_train_APs, epoch_val_APs, epoch_test_APs = [], [], []
  
      train_loader = GraphDataLoader(
          trainset,
          batch_size=params.batch_size,
          shuffle=True,
          collate_fn=dataset.collate,
          pin_memory=True,
      )
      val_loader = GraphDataLoader(
          valset,
          batch_size=params.batch_size,
          shuffle=False,
          collate_fn=dataset.collate,
          pin_memory=True,
      )
      test_loader = GraphDataLoader(
          testset,
          batch_size=params.batch_size,
          shuffle=False,
          collate_fn=dataset.collate,
          pin_memory=True,
      )
  
      with tqdm(range(450), unit="epoch") as t:
          for epoch in t:
              t.set_description("Epoch %d" % epoch)
  
              epoch_train_loss, epoch_train_ap = train_epoch(
                  model, optimizer, device, train_loader
              )
              epoch_val_loss, epoch_val_ap = evaluate_network(
                  model, device, val_loader
              )
  
              epoch_train_losses.append(epoch_train_loss)
              epoch_val_losses.append(epoch_val_loss)
              epoch_train_APs.append(epoch_train_ap.item())
              epoch_val_APs.append(epoch_val_ap.item())
  
              _, epoch_test_ap = evaluate_network(
                  model, device, test_loader
              )
  
              epoch_test_APs.append(epoch_test_ap.item())
  
              t.set_postfix(
                  train_loss=epoch_train_loss,
                  train_AP=epoch_train_ap.item(),
                  val_AP=epoch_val_ap.item(),
                  refresh=False,
              )
  
              scheduler.step(-epoch_val_ap.item())
  
              if optimizer.param_groups[0]["lr"] < 1e-5:
                  print("\n!! LR EQUAL TO MIN LR SET.")
                  break
  
              print("")
  
      best_val_epoch = np.argmax(np.array(epoch_val_APs))
      best_train_epoch = np.argmax(np.array(epoch_train_APs))
      best_val_ap = epoch_val_APs[best_val_epoch]
      best_val_test_ap = epoch_test_APs[best_val_epoch]
      best_val_train_ap = epoch_train_APs[best_val_epoch]
      best_train_ap = epoch_train_APs[best_train_epoch]
  
      print("Best Train AP: {:.4f}".format(best_train_ap))
      print("Best Val AP: {:.4f}".format(best_val_ap))
      print("Test AP of Best Val: {:.4f}".format(best_val_test_ap))
      print("Train AP of Best Val: {:.4f}".format(best_val_train_ap))
  
imports: import argparse
  import random
  import dgl
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.optim
  from dgl.dataloading import GraphDataLoader
  from ogb.graphproppred import Evaluator
  from ogb.graphproppred.mol_encoder import AtomEncoder
  from preprocessing import prepare_dataset
  from torch.utils.data import Dataset
  from tqdm import tqdm
label_desc: Use image node_id 7 for calling a global function with example usage: train(dataset, params) without return types