code: def _run_train_step(self, data, mode='train'):
          
          epoch_size = ((len(data) // self.batch_size) - 1) // self.num_steps
          costs = 0.0
          iters = 0
          step = 0
          state = self._init_state.eval()
          op = self._train_op if mode == 'train' else tf.no_op()
  
          for step, (x, y) in enumerate(
              utilities.seq_data_iterator(
                  data, self.batch_size, self.num_steps)):
              cost, state, _ = self.tf_session.run(
                  [self.cost, self.final_state, op],
                  {self.input_data: x,
                   self.input_labels: y,
                   self._init_state: state})
  
              costs += cost
              iters += self.num_steps
  
          if step % (epoch_size // 10) == 10:
              print("%.3f perplexity" % (step * 1.0 / epoch_size))
  
          return np.exp(costs / iters)
docs: Run a single training step.
  
          :param data: input data
          :param mode: 'train' or 'test'.