code: def train(epoch):
      random.shuffle(train_data)
      i = 0
      epoch_start = time.time()
      while i < len(train_data):
          dy.renew_cg()
          losses = []
          for lbl, img in train_data[i : i + args.batch_size]:
              loss = network.create_network_return_loss(
                  img, lbl, dropout=True
              )
              losses.append(loss)
          mbloss = dy.average(losses)
          if (int(i / args.batch_size)) % args.log_interval == 0:
              print(
                  "Train Epoch: {} [{}/{} ({:.0f}%)]\tLoss: {:.6f}".format(
                      epoch,
                      i,
                      len(train_data),
                      100.0 * i / len(train_data),
                      mbloss.value(),
                  )
              )
          mbloss.backward()
          trainer.update()
          i += args.batch_size
      epoch_end = time.time()
      print("{} s per epoch".format(epoch_end - epoch_start))
  
file_path: dynet/examples/mnist/basic-mnist-benchmarks/mnist_dynet_autobatch.py
imports: from __future__ import division
  import os
  import struct
  import argparse
  import random
  import time
  import numpy
  import dynet
label_desc: Use image node_id 2 for calling a global function with example usage: train(epoch) without return types