code: def test_einsum_complete_sharing_reuse_cache(
      equation, plates, backend, einsum_impl, same_lazy
  ):
      (
          inputs,
          outputs,
          sizes,
          operands,
          funsor_operands,
      ) = make_einsum_example(equation)
  
      with reflect:
          lazy_expr1 = einsum_impl(
              equation, *funsor_operands, backend=backend, plates=plates
          )
          lazy_expr2 = (
              lazy_expr1
              if same_lazy
              else einsum_impl(
                  equation,
                  *funsor_operands,
                  backend=backend,
                  plates=plates,
              )
          )
  
      cache = {}
      with memoize(cache) as cache:
          expr1 = reinterpret(lazy_expr1)
  
      with memoize(cache):
          expr2 = reinterpret(lazy_expr2)
  
      expr3 = reinterpret(lazy_expr1)
  
      assert expr1 is expr2
      assert expr1 is not expr3
  
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 3 for calling a global function with example usage: test_einsum_complete_sharing_reuse_cache(equation, plates, backend, einsum_impl, same_lazy) without return types