code: def train(
      model, dataloader, optimizer, criterion, device, num_classes
  ):
      #####################################################################
      # (HIGHLIGHT) Train the model for one epoch.
      #
      # - Iterates over the data loader, fetching mini-batches of graph data.
      # - For each mini-batch, it performs a forward pass, computes loss, and
      #   updates the model parameters.
      # - The function returns the average loss and accuracy for the epoch.
      #
      # Parameters:
      #   model: The GraphSAGE model.
      #   dataloader: DataLoader that provides mini-batches of graph data.
      #   optimizer: Optimizer used for updating model parameters.
      #   criterion: Loss function used for training.
      #   device: The device (CPU/GPU) to run the training on.
      #####################################################################
  
      model.train()  # Set the model to training mode
      total_loss = 0  # Accumulator for the total loss
      total_correct = (
          0  # Accumulator for the total number of correct predictions
      )
      total_samples = (
          0  # Accumulator for the total number of samples processed
      )
      num_batches = (
          0  # Counter for the number of mini-batches processed
      )
  
      for minibatch in dataloader:
          node_features = minibatch.node_features["feat"]
          labels = minibatch.labels
          optimizer.zero_grad()
          out = model(minibatch.blocks, node_features, device)
          loss = criterion(out, labels)
          total_loss += loss.item()
          total_correct += MF.accuracy(
              out, labels, task="multiclass", num_classes=num_classes
          ) * labels.size(0)
          total_samples += labels.size(0)
          loss.backward()
          optimizer.step()
          num_batches += 1
      avg_loss = total_loss / num_batches
      avg_accuracy = total_correct / total_samples
      return avg_loss, avg_accuracy
  
file_path: dgl/examples/sampling/pyg/node_classification.py
imports: import argparse
  import dgl.graphbolt
  import torch
  import torch.nn.functional
  import torchmetrics.functional
  from torch_geometric.nn import SAGEConv
label_desc: Use image node_id 2 for calling a global function with example usage: train(model, dataloader, optimizer, criterion, device, num_classes) and returns: avg_loss,  avg_accuracy