code: def linearize_metrics(logged_metrics):
      """
      Group metrics by name.
  
      Takes a list of individual measurements, possibly belonging
      to different metrics and groups them by name.
  
      :param logged_metrics: A list of ScalarMetricLogEntries
      :return: Measured values grouped by the metric name:
      {"metric_name1": {"steps": [0,1,2], "values": [4, 5, 6],
      "timestamps": [datetime, datetime, datetime]},
      "metric_name2": {...}}
      """
      metrics_by_name = {}
      for metric_entry in logged_metrics:
          if metric_entry.name not in metrics_by_name:
              metrics_by_name[metric_entry.name] = {
                  "steps": [],
                  "values": [],
                  "timestamps": [],
                  "name": metric_entry.name,
              }
          metrics_by_name[metric_entry.name]["steps"].append(
              metric_entry.step
          )
          metrics_by_name[metric_entry.name]["values"].append(
              metric_entry.value
          )
          metrics_by_name[metric_entry.name]["timestamps"].append(
              metric_entry.timestamp
          )
      return metrics_by_name
  
file_path: sacred/sacred/metrics_logger.py
imports: import datetime
  import sacred.optional
  from queue import Queue, Empty
label_desc: Use image node_id 1 for calling a global function with example usage: linearize_metrics(logged_metrics) and returns: metrics_by_name