code: def strip_magics(source):
      """
      Given the source of a cell, filter out all cell and line magics.
      """
      filtered = []
      for line in source.splitlines():
          if not line.startswith("%"):
              filtered.append(line)
      return "\n".join(filtered)
  
imports: import ast
  from nbconvert.preprocessors import Preprocessor
label_desc: Use image node_id 4 for calling a global function with example usage: strip_magics(source) and returns: str