  
  
  def train_ch5(net, train_iter, test_iter, batch_size, trainer, ctx,
                num_epochs):
      """Train and evaluate a model on CPU or GPU."""
      print('training on', ctx)
      loss = gloss.SoftmaxCrossEntropyLoss()
      for epoch in range(1, num_epochs + 1):
          train_l_sum = 0
          train_acc_sum = 0
 
</s> remove     for epoch in range(1, num_epochs + 1):
        train_l_sum = 0
        train_acc_sum = 0
        start = time.time()
 </s> add     for epoch in range(num_epochs):
        train_l_sum, train_acc_sum, n, start = 0.0, 0.0, 0, time.time() </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               % (epoch, train_l_sum / len(train_iter),
                 train_acc_sum / len(train_iter), test_acc))
 </s> add               % (epoch + 1, train_l_sum / n, train_acc_sum / n, test_acc)) </s> remove     for epoch in range(1, num_epochs + 1):
        train_l_sum, train_acc_sum, n, m = 0.0, 0.0, 0.0, 0.0
        start = time.time()
 </s> add     for epoch in range(num_epochs):
        train_l_sum, train_acc_sum, n, m, start = 0.0, 0.0, 0, 0, time.time() </s> remove                     prefix, pred_len, model, vocab_size,
                    ctx, idx_to_char, char_to_idx))
 </s> add                     prefix, pred_len, model, vocab_size, ctx, idx_to_char,
                    char_to_idx))
    """Train and evaluate a model with CPU or GPU."""
  
  
  def train_ch5(net, train_iter, test_iter, batch_size, trainer, ctx,
                num_epochs):
    """Train and evaluate a model with CPU or GPU."""
      print('training on', ctx)
      loss = gloss.SoftmaxCrossEntropyLoss()
      for epoch in range(1, num_epochs + 1):
          train_l_sum = 0
          train_acc_sum = 0
keep keep keep keep replace keep keep keep keep keep
 gb 0.8.9, fix acc, loss computations 
gluonbook/utils.py