code: def get_data(doc: str) -> tuple[str, dict[str, Any]]:
      """
      Extract meta-data from a text document.
  
      Returns a tuple of document and a data dict.
      """
      data = {}
  
      # First try YAML
      if m := YAML_RE.match(doc):
          try:
              data = yaml.load(m.group(1), SafeLoader)
              if isinstance(data, dict):
                  doc = doc[m.end() :].lstrip("\n")
              else:
                  data = {}  # type: ignore[unreachable]
          except Exception:
              pass
          return doc, data
  
      # No YAML delimiters. Try MultiMarkdown style
      lines = doc.replace("\r\n", "\n").replace("\r", "\n").split("\n")
  
      key = None
      while lines:
          line = lines.pop(0)
  
          if line.strip() == "":
              break  # blank line - done
          if m1 := META_RE.match(line):
              key = m1.group("key").lower().strip()
              value = m1.group("value").strip()
              if key in data:
                  data[key] += f" {value}"
              else:
                  data[key] = value
          else:
              m2 = META_MORE_RE.match(line)
              if m2 and key:
                  # Add another line to existing key
                  data[key] += " {}".format(m2.group("value").strip())
              else:
                  lines.insert(0, line)
                  break  # no meta data - done
      return "\n".join(lines).lstrip("\n"), data
  
imports: from __future__ import annotations
  import re
  from typing import Any
  import yaml
label_desc: Use image node_id 1 for calling a global function with example usage: get_data(doc) and returns: str,  data, doc,  data