def format_metrics(metrics, mode):
  """Format metrics for logging."""
  result = ''
  for metric in metrics:
    result += '{}_{} = {:.4f} | '.format(mode, metric, float(metrics[metric]))
  return result