from typing import Dict


def metrics_one_linear(metrics: Dict[str, float]) -> str:
  """Summarize training metrics into a one line string."""

  def matching_metrics_string(like, style='{}={:1.4f}', delimiter='/'):
    values = [(k.split('/')[-1], v)
              for k, v in sorted(metrics.items())
              if like in k]
    return delimiter.join(style.format(*kv) for kv in values)

  return ('loss: {:1.7f}, abs_error: {}, rel_error: {}, below_baseline: {}'
          .format(metrics['loss'],
                  matching_metrics_string('mae'),
                  matching_metrics_string('mean_abs_relative_error'),
                  matching_metrics_string('frac_below_baseline')))