code: def comment_out_magics(source):
      """
      Utility used to make sure AST parser does not choke on unrecognized
      magics.
      """
      filtered = []
      for line in source.splitlines():
          if line.strip().startswith("%"):
              filtered.append("# " + line)
          else:
              filtered.append(line)
      return "\n".join(filtered)
  
imports: import ast
  from nbconvert.preprocessors import Preprocessor
label_desc: Use image node_id 1 for calling a global function with example usage: comment_out_magics(source) and returns: str