code: def dump_yaml_blocks(data, compact=True):
      """Where possible, we try to use a more compact metadata style.
  
      For blocks with no nested dicts, the block is denoted by starting colons::
  
          :other: true
          :tags: [hide-output, show-input]
  
      For blocks with nesting the block is enlosed by ``---``::
  
          ---
          other:
              more: true
          tags: [hide-output, show-input]
          ---
      """
      string = yaml.dump(data, Dumper=CompactDumper)
      lines = string.splitlines()
      if compact and all(line and line[0].isalpha() for line in lines):
          return "\n".join([f":{line}" for line in lines]) + "\n\n"
      return f"---\n{string}---\n"
  
imports: import json
  import re
  import warnings
  from textwrap import dedent
  import nbformat
  import yaml
  from .cell_to_text import three_backticks_or_more
label_desc: Use image node_id 9 for calling a global function with example usage: dump_yaml_blocks(data, compact) and returns: str, string, str, unknown