code: def process_titles(lines):
      """Converts rst titles to markdown titles."""
      title_chars = """= - ` : ' " ~ ^ _ * + # < >""".split(" ")
      title_levels = {}
      new_lines = []
      for line in lines:
          if (
              len(new_lines) > 0
              and len(line) >= len(new_lines[-1])
              and len(set(line)) == 1
              and line[0] in title_chars
              and line != "::"
          ):
              char = line[0]
              level = title_levels.get(char, len(title_levels) + 1)
              if level not in title_levels:
                  title_levels[char] = level
              new_lines[-1] = f"{'#' * level} {new_lines[-1]}"
          else:
              new_lines.append(line)
      return new_lines
  
imports: import nbformat
  import os
  import re
  import shutil
label_desc: Use image node_id 2 for calling a global function with example usage: process_titles(lines) and returns: new_lines