code: def train(g, features, labels, masks, model):
      # Define train/val samples, loss function and optimizer.
      train_mask, val_mask = masks
      loss_fcn = nn.CrossEntropyLoss()
      optimizer = torch.optim.Adam(
          model.parameters(), lr=1e-2, weight_decay=5e-4
      )
  
      # Training loop.
      for epoch in range(200):
          t0 = time.time()
          model.train()
          logits = model(g, features)
          loss = loss_fcn(logits[train_mask], labels[train_mask])
          optimizer.zero_grad()
          loss.backward()
          optimizer.step()
          t1 = time.time()
          acc = evaluate(g, features, labels, val_mask, model)
          print(
              f"Epoch {epoch:05d} | Loss {loss.item():.4f} | Accuracy {acc:.4f} | "
              f"Time {t1 - t0:.4f}"
          )
  
file_path: dgl/examples/core/graphsage/node_classification.py
imports: import argparse
  import time
  import dgl.nn
  import torch
  import torch.nn
  import torch.nn.functional
  from dgl import AddSelfLoop
  from dgl.data import CiteseerGraphDataset, CoraGraphDataset, PubmedGraphDataset
label_desc: Use image node_id 2 for calling a global function with example usage: train(g, features, labels, masks, model) without return types