code: def train(epoch):
      print("\nEpoch: %d" % epoch)
      net.train()
      stats = adl.Accumulator()
      for inputs, targets in trainloader:
          inputs, targets = inputs.to(device), targets.to(device)
          optimizer.zero_grad()
          outputs = net(inputs)
          loss = criterion(outputs, targets)
          loss.backward()
          optimizer.step()
  
          stats["loss_sum"] += loss.item() * targets.size(0)
          _, predicted = outputs.max(1)
          stats["total"] += targets.size(0)
          stats["correct"] += predicted.eq(targets).sum().item()
  
      trainloader.to_tensorboard(
          writer, epoch, tag_prefix="AdaptDL/Data/"
      )
      net.to_tensorboard(writer, epoch, tag_prefix="AdaptDL/Model/")
      with stats.synchronized():
          stats["loss_avg"] = stats["loss_sum"] / stats["total"]
          stats["accuracy"] = stats["correct"] / stats["total"]
          writer.add_scalar("Loss/Train", stats["loss_avg"], epoch)
          writer.add_scalar("Accuracy/Train", stats["accuracy"], epoch)
          print("Train:", stats)
  
file_path: nni/examples/trials/cifar10_pytorch/main_adl.py
imports: import torch
  import torch.nn
  import torch.optim
  import torch.backends.cudnn
  import torch.distributed
  import torchvision
  import torchvision.transforms
  import os
  import argparse
  from models import *
  import adaptdl
  import adaptdl.torch
  from torch.optim.lr_scheduler import MultiStepLR
  from torch.utils.tensorboard import SummaryWriter
  import nni
label_desc: Use image node_id 1 for calling a global function with example usage: train(epoch) without return types