code: def test_nested_complete_sharing_direct():
      (
          inputs,
          outputs,
          sizes,
          operands,
          funsor_operands,
      ) = make_einsum_example("ab,bc,cd->d")
      ab, bc, cd = funsor_operands
  
      # avoids the complicated internal interpreter usage of the nested optimized einsum tests above
      with reflect:
          c1 = (ab * bc).reduce(ops.add, frozenset({"a", "b"}))
          d1 = (c1 * cd).reduce(ops.add, frozenset({"c"}))
  
          # this does not trigger a second alpha-renaming
          c2 = (ab * bc).reduce(ops.add, frozenset({"a", "b"}))
          d2 = (c2 * cd).reduce(ops.add, frozenset({"c"}))
  
      with memoize():
          assert reinterpret(c1) is reinterpret(c2)
          assert reinterpret(d1) is reinterpret(d2)
  
file_path: funsor/test/test_memoize.py
imports: import numpy
  import pytest
  import funsor.ops
  from funsor.cnf import BACKEND_TO_EINSUM_BACKEND, BACKEND_TO_LOGSUMEXP_BACKEND
  from funsor.einsum import einsum, naive_plated_einsum
  from funsor.interpretations import memoize
  from funsor.interpreter import reinterpret
  from funsor.tensor import numeric_array
  from funsor.terms import reflect
  from funsor.testing import excludes_backend, make_einsum_example, xfail_param
  from funsor.util import get_backend
label_desc: Use image node_id 6 for calling a global function with example usage: test_nested_complete_sharing_direct() without return types