code: def exec_then_eval(code, namespace=None):
      """Exec a code block & return evaluation of the last line"""
      # TODO: make this less brittle.
      namespace = namespace or {}
  
      block = ast.parse(code, mode="exec")
      last = ast.Expression(block.body.pop().value)
  
      exec(compile(block, "<string>", mode="exec"), namespace)
      return eval(compile(last, "<string>", mode="eval"), namespace)
  
file_path: pdvega/doc/sphinxext/pdvega_ext/utils.py
imports: import ast
  import json
  import importlib
  from hashlib import md5
  from itertools import tee, chain
label_desc: Use image node_id 2 for calling a global function with example usage: exec_then_eval(code, namespace) and returns: eval