code: def run_epoch(
      network, X, y, cost=None, acc=None, batch_size=100, shuffle=False
  ):
      """Run a given non time-series network by the given cost function, test data, batch_size etc.
      for one epoch.
  
      Parameters
      ----------
      network : TensorLayer Model
          the network to be trained.
      X : numpy.array
          The input of training data
      y : numpy.array
          The target of training data
      cost : TensorLayer or TensorFlow loss function
          Metric for loss function, e.g tl.cost.cross_entropy.
      acc : TensorFlow/numpy expression or None
          Metric for accuracy or others. If None, would not print the information.
      batch_size : int
          The batch size for training and evaluating.
      shuffle : boolean
          Indicating whether to shuffle the dataset in training.
  
      Returns
      -------
      loss_ep : Tensor. Average loss of this epoch. None if 'cost' is not given.
      acc_ep : Tensor. Average accuracy(metric) of this epoch. None if 'acc' is not given.
      n_step : int. Number of iterations taken in this epoch.
      """
      network.eval()
      loss_ep = 0
      acc_ep = 0
      n_step = 0
      for X_batch, y_batch in tl.iterate.minibatches(
          X, y, batch_size, shuffle=shuffle
      ):
          _loss, _acc = _run_step(
              network, X_batch, y_batch, cost=cost, acc=acc
          )
          if cost is not None:
              loss_ep += _loss
          if acc is not None:
              acc_ep += _acc
          n_step += 1
  
      loss_ep = loss_ep / n_step if cost is not None else None
      acc_ep = acc_ep / n_step if acc is not None else None
  
      return loss_ep, acc_ep, n_step
  
imports: import os
  import random
  import subprocess
  import sys
  import time
  from collections import Counter
  from sys import exit
  from sys import platform
  import numpy
  import tensorflow
  from sklearn.metrics import accuracy_score, confusion_matrix, f1_score
  import tensorlayer
label_desc: Use image node_id 15 for calling a global function with example usage: run_epoch(network, X, y, cost, acc, batch_size, shuffle) and returns: loss_ep,  acc_ep,  n_step