code: def train(model, dataloaders, optimizer, args, scheduler=None):
      # training loop
      val_max = 0
      best_model = model
      t_accu = []
      v_accu = []
      e_accu = []
  
      for epoch in range(1, args.epochs):
          t_accu_sum = 0
          t_accu_cnt = 0
          for iter_i, batch in enumerate(dataloaders["train"]):
              batch.to(args.device)
              model.train()
              optimizer.zero_grad()
              pred = model(batch)
              loss = model.loss(pred, batch.edge_label.type(pred.dtype))
              loss.backward()
              optimizer.step()
  
              pred = torch.sigmoid(pred)
              t_accu_sum += roc_auc_score(
                  batch.edge_label.flatten().cpu().numpy(),
                  pred.flatten().data.cpu().numpy(),
              )
              t_accu_cnt += 1
  
              if scheduler is not None:
                  scheduler.step()
  
              log = "Epoch: {:03d}, Train: {:.4f}, Val: {:.4f}, Test: {:.4f}, Loss: {:.4f}"
              accs = test(
                  model,
                  {
                      key: val
                      for key, val in dataloaders.items()
                      if key != "train"
                  },
                  args,
              )
              # TODO: add accs train here
              accs["train"] = t_accu_sum / t_accu_cnt
  
              t_accu.append(accs["train"])
              v_accu.append(accs["val"])
              e_accu.append(accs["test"])
  
              print(
                  log.format(
                      epoch,
                      accs["train"],
                      accs["val"],
                      accs["test"],
                      loss.item(),
                  )
              )
              if val_max < accs["val"]:
                  val_max = accs["val"]
                  best_model = copy.deepcopy(model)
  
      log = "Best, Train: {:.4f}, Val: {:.4f}, Test: {:.4f}"
      accs = test(best_model, dataloaders, args)
      print(log.format(accs["train"], accs["val"], accs["test"]))
  
imports: import copy
  import argparse
  import torch
  import torch.nn.functional
  import torch_geometric.nn
  import torch_geometric.transforms
  from sklearn.metrics import *
  from torch.utils.data import DataLoader
  from torch_geometric.datasets import Planetoid
  from deepsnap.dataset import GraphDataset
  from deepsnap.batch import Batch
label_desc: Use image node_id 2 for calling a global function with example usage: train(model, dataloaders, optimizer, args, scheduler) without return types