import tensorflow as tf



def test(model, eval_data):
  """Computes the average loss on eval_data, which should be a Dataset."""
  avg_loss = tfe.metrics.Mean("loss")
  for (labels, chars, sequence_length) in tfe.Iterator(eval_data):
    predictions = model((chars, sequence_length), training=False)
    avg_loss(loss(labels, predictions))
  print("eval/loss: %.6f\n" % avg_loss.result())
  with tf.contrib.summary.always_record_summaries():
    tf.contrib.summary.scalar("loss", avg_loss.result())


def train_one_epoch(model, optimizer, train_data, log_interval=10):
  """Trains model on train_data using optimizer."""

  tf.train.get_or_create_global_step()

