code: def _train_epoch(sess, epoch):
      start_time = time.time()
      loss = 0.0
      corr = 0.0
      num_tokens = 0.0
  
      fetches = {
          "mle_loss": mle_loss,
          "correct": corrects,
      }
      fetches["train_op"] = train_op
  
      mode = tf.estimator.ModeKeys.TRAIN
      num_inst = 0
      for batch in iterate_batch(
          data_train, config.batch_size, shuffle=True
      ):
          word, char, ner, mask, length = batch
          feed_dict = {
              inputs: word,
              chars: char,
              targets: ner,
              masks: mask,
              seq_lengths: length,
              global_step: epoch,
              tx.global_mode(): mode,
          }
  
          rets = sess.run(fetches, feed_dict)
          nums = np.sum(length)
          num_inst += len(word)
          loss += rets["mle_loss"] * nums
          corr += rets["correct"]
          num_tokens += nums
  
          print(
              "train: %d (%d/%d) loss: %.4f, acc: %.2f%%"
              % (
                  epoch,
                  num_inst,
                  len(data_train),
                  loss / num_tokens,
                  corr / num_tokens * 100,
              )
          )
      print(
          "train: %d loss: %.4f, acc: %.2f%%, time: %.2fs"
          % (
              epoch,
              loss / num_tokens,
              corr / num_tokens * 100,
              time.time() - start_time,
          )
      )
  
file_path: texar/examples/sequence_tagging/ner.py
imports: import os
  import time
  import importlib
  import numpy
  import tensorflow
  import texar.tf
  from examples.sequence_tagging.conll_reader import create_vocabs, read_data, iterate_batch, load_glove, construct_init_word_vecs
  from examples.sequence_tagging.conll_writer import CoNLLWriter
  from examples.sequence_tagging import scores
label_desc: Use image node_id 1 for calling a global function with example usage: _train_epoch(sess, epoch) without return types