code: def train_epoch(
      network,
      X,
      y,
      cost,
      train_op=tf.optimizers.Adam(learning_rate=0.0001),
      acc=None,
      batch_size=100,
      shuffle=True,
  ):
      """Training a given non time-series network by the given cost function, training 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.
      train_op : TensorFlow optimizer
          The optimizer for training e.g. tf.optimizers.Adam().
      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.
      acc_ep : Tensor or None. Average accuracy(metric) of this epoch. None if acc is not given.
      n_step : int. Number of iterations taken in this epoch.
  
      """
      network.train()
      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 = _train_step(
              network,
              X_batch,
              y_batch,
              cost=cost,
              train_op=train_op,
              acc=acc,
          )
  
          loss_ep += _loss
          if acc is not None:
              acc_ep += _acc
          n_step += 1
  
      loss_ep = loss_ep / n_step
      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 14 for calling a global function with example usage: train_epoch(network, X, y, cost, train_op, acc, batch_size, shuffle) and returns: loss_ep,  acc_ep,  n_step