docstr: Store new measurements into metrics.json.
code: def log_metrics(self, metrics_by_name, info):
      """Store new measurements into metrics.json."""
      try:
          metrics_path = os.path.join(self.dir, "metrics.json")
          with open(metrics_path, "r") as f:
              saved_metrics = json.load(f)
      except IOError:
          # We haven't recorded anything yet. Start Collecting.
          saved_metrics = {}
  
      for metric_name, metric_ptr in metrics_by_name.items():
          if metric_name not in saved_metrics:
              saved_metrics[metric_name] = {
                  "values": [],
                  "steps": [],
                  "timestamps": [],
              }
  
          saved_metrics[metric_name]["values"] += metric_ptr["values"]
          saved_metrics[metric_name]["steps"] += metric_ptr["steps"]
  
          # Manually convert them to avoid passing a datetime dtype handler
          # when we're trying to convert into json.
          timestamps_norm = [
              ts.isoformat() for ts in metric_ptr["timestamps"]
          ]
          saved_metrics[metric_name]["timestamps"] += timestamps_norm
  
      self.save_json(saved_metrics, "metrics.json")
  
imports: import json
  import os
  import os.path
  from pathlib import Path
  from typing import Optional
  import warnings
  from shutil import copyfile, SameFileError
  from sacred.commandline_options import cli_option
  from sacred.dependencies import get_digest
  from sacred.observers.base import RunObserver
  from sacred import optional
  from sacred.serializer import flatten
  from sacred.utils import PathType
label_desc: Use image node_id 22 for calling the FileStorageObserver obj's underlying member method code with example usage: obj.log_metrics(metrics_by_name, info) without return types