code: def train_epoch(
      model, optimizer, loss_function, train_loader, epoch, device="cpu"
  ):
      # Mark training flag
      model.train()
      for batch_idx, (inputs, targets) in enumerate(train_loader):
          inputs, targets = inputs.to(device), targets.to(device)
          optimizer.zero_grad()
          outputs = model(inputs)
          loss = loss_function(outputs, targets)
          loss.backward()
          optimizer.step()
          if batch_idx % 499 == 0:
              print(
                  "Train Epoch: {} [{}/{} ({:.0f}%)]\tLoss: {:.6f}".format(
                      epoch,
                      batch_idx * len(inputs),
                      len(train_loader.dataset),
                      100.0 * batch_idx / len(train_loader),
                      loss.item(),
                  )
              )
  
file_path: BentoML/examples/pytorch_mnist/train.py
imports: import argparse
  import os
  import random
  import model
  import numpy
  import torch
  from sklearn.model_selection import KFold
  from torch import nn
  from torchvision import transforms
  from torchvision.datasets import MNIST
  import bentoml
label_desc: Use image node_id 3 for calling a global function with example usage: train_epoch(model, optimizer, loss_function, train_loader, epoch, device) without return types