              print('epoch %d, perplexity %f, time %.2f sec' % (
                  epoch + 1, math.exp(l_sum / (t + 1)), time.time() - start))
              for prefix in prefixes:
                  print(' -', predict_rnn_gluon(
                      prefix, pred_len, model, vocab_size,
                      ctx, idx_to_char, char_to_idx))
  
  
  def train_ch3(net, train_iter, test_iter, loss, num_epochs, batch_size,
                params=None, lr=None, trainer=None):
      """Train and evaluate a model on CPU."""
 
</s> remove                 epoch + 1, math.exp(l_sum / (t + 1)), time.time() - start))
 </s> add                 epoch + 1, math.exp(l_sum / n), time.time() - start)) </s> remove                 epoch + 1, math.exp(l_sum / (t + 1)), time.time() - start))
 </s> add                 epoch + 1, math.exp(l_sum / n), time.time() - start)) </s> remove     """Train and evaluate a model on CPU."""
    for epoch in range(1, num_epochs + 1):
        train_l_sum = 0
        train_acc_sum = 0
 </s> add     """Train and evaluate a model with CPU."""
    for epoch in range(num_epochs):
        train_l_sum, train_acc_sum, n = 0.0, 0.0, 0 </s> remove             l_sum += l.asscalar()
 </s> add             l_sum += l.asscalar() * y.size
            n += y.size </s> remove             sgd(params, lr, 1)
            l_sum += l.asscalar()
 </s> add             gb.sgd(params, lr, 1)
            l_sum += l.asscalar() * y.size
            n += y.size
                    prefix, pred_len, model, vocab_size, ctx, idx_to_char,
                    char_to_idx))
              print('epoch %d, perplexity %f, time %.2f sec' % (
                  epoch + 1, math.exp(l_sum / (t + 1)), time.time() - start))
              for prefix in prefixes:
                  print(' -', predict_rnn_gluon(
                    prefix, pred_len, model, vocab_size, ctx, idx_to_char,
                    char_to_idx))
                    prefix, pred_len, model, vocab_size, ctx, idx_to_char,
                    char_to_idx))
  
  
  def train_ch3(net, train_iter, test_iter, loss, num_epochs, batch_size,
                params=None, lr=None, trainer=None):
      """Train and evaluate a model on CPU."""
keep keep keep keep replace replace keep keep keep keep keep
 gb 0.8.9, fix acc, loss computations 
gluonbook/utils.py