code: def _train_step(
      network,
      X_batch,
      y_batch,
      cost,
      train_op=tf.optimizers.Adam(learning_rate=0.0001),
      acc=None,
  ):
      with tf.GradientTape() as tape:
          y_pred = network(X_batch)
          _loss = cost(y_pred, y_batch)
      grad = tape.gradient(_loss, network.trainable_weights)
      train_op.apply_gradients(zip(grad, network.trainable_weights))
      if acc is not None:
          _acc = acc(y_pred, y_batch)
          return _loss, _acc
      else:
          return _loss, None
  
file_path: TensorLayer/examples/quantized_net/tutorial_ternaryweight_cifar10_tfrecord.py
imports: import multiprocessing
  import time
  import numpy
  import tensorflow
  import tensorlayer
  from tensorlayer.layers import Conv2d, Dense, Flatten, Input, LocalResponseNorm, MaxPool2d, TernaryConv2d, TernaryDense
  from tensorlayer.models import Model
label_desc: Use image node_id 6 for calling a global function with example usage: _train_step(network, X_batch, y_batch, cost, train_op, acc) and returns: _loss,  _acc, _loss,  None