code: def _safe_literal_eval(source, to_df=False, none_if_error=False):
      """
      Evaluates a literal, if the code cannot be parsed, it returns the original
      source as a string unless non_if_error is True, in such case it returns
      None
      """
      try:
          result = ast.literal_eval(source)
  
          if isinstance(result, Mapping) and to_df:
              result = pd.DataFrame(result, index=[0])
  
          return result
  
      except (SyntaxError, ValueError):
          return None if none_if_error else source.strip()
  
imports: import base64
  from collections.abc import Mapping
  import ast
  import parso
  import pandas
  import nbformat
  from IPython.display import Image, HTML
label_desc: Use image node_id 1 for calling a global function with example usage: _safe_literal_eval(source, to_df, none_if_error) and returns: result, unknown