code: def log_metrics(metrics, summ_writer, log_prefix, step, history=None):
    
    rjust_len = max([len(name) for name in metrics])
    for name, value in six.iteritems(metrics):
      step_log(step, "%s %s | % .8f" % (
          log_prefix.ljust(5), name.rjust(rjust_len), value))
      full_name = "metrics/" + name
      if history:
        history.append(log_prefix, full_name, step, value)
      if summ_writer:
        summ_writer.scalar(full_name, value, step)
docs: Log metrics to summary writer and history.