code: def check_compiler(expr):
      # Create a random substitution.
      subs = {k: randn(d.shape) for k, d in expr.inputs.items()}
      expected = expr(**subs)
      expected_data = extract_data(expected)
  
      # Execute a funsor program.
      program = compile_funsor(expr)
      actual = program(**subs)
      assert_close(actual, expected_data)
  
      # Execute a printed program.
      code = program.as_code(name="program2")
      print(code)
      env = {}
      exec(code, None, env)
      actual = env["program2"](**subs)
      assert_close(actual, expected_data)
  
imports: import functools
  import pytest
  import funsor.ops
  from funsor.compiler import compile_funsor
  from funsor.domains import Real, Reals
  from funsor.interpretations import reflect
  from funsor.optimizer import apply_optimizer
  from funsor.sum_product import sum_product
  from funsor.tensor import Tensor
  from funsor.terms import Number, Tuple, Variable
  from funsor.testing import assert_close, randn
label_desc: Use image node_id 4 for calling a global function with example usage: check_compiler(expr) without return types