code: def train(
      epoch, model, optimizer, train_loader, device, train_log_interval
  ):
      model.train()
      for batch_idx, (data, target) in enumerate(train_loader):
          data, target = data.to(device), target.to(device)
  
          optimizer.zero_grad()
          output = model(data)
          loss = F.cross_entropy(output, target)
          loss.backward()
          optimizer.step()
  
          if batch_idx % train_log_interval == 0:
              print(
                  f"train epoch: {epoch}"
                  f" [{batch_idx * len(data)}/{len(train_loader.dataset)}"
                  f" ({100. * batch_idx / len(train_loader):.0f}%)]"
                  f"\tLoss: {loss.item():.6f}"
              )
  
file_path: labml/samples/pytorch/mnist/a_no_labml.py
imports: import torch
  import torch.nn
  import torch.nn.functional
  import torch.optim
  import torch.utils.data
  from torchvision import datasets, transforms
  from labml import lab
label_desc: Use image node_id 1 for calling a global function with example usage: train(epoch, model, optimizer, train_loader, device, train_log_interval) without return types