def _ExtractResNetThroughput(output):
  """Extract throughput from Horovod output.

  Args:
    output: Horovod output

  Returns:
    A tuple of:
      Average throuput in images per second (float)
      Unit of the throughput metric (str)
  """
  # Start from last line and iterate backwards.
  avg_throughput = 0
  for line in output.splitlines()[::-1]:
    if 'train_throughput' in line:
      split_line = line.split()
      avg_throughput = float(split_line[-1])
      break
  return round(avg_throughput, 1), 'images/second'