code: def extract_spec(path: Path) -> dict:
      """
      Given a path to a log file, find and return the "spec" dictionary.
      """
      with path.open() as f:
          for line in f.readlines():
              line = line.strip()
              try:
                  loaded_line = json.loads(line)
                  if "spec" in loaded_line:
                      return loaded_line["spec"]
              except json.decoder.JSONDecodeError:
                  print(f"Skipping line: {line}")
                  continue
      raise ValueError(f"Could not find spec in {path}")
  
imports: import json
  from pathlib import Path
  from typing import Union
label_desc: Use image node_id 4 for calling a global function with example usage: extract_spec(path) and returns: loaded_line