code: def test_cache_complex():
      """
      Test caching on a complicated expression with multiple symbols appearing
      multiple times.
      """
      expr = x**2 + (y - sy.exp(x)) * sy.sin(z - x * y)
      symbol_names = {s.name for s in expr.free_symbols}
      expr_t = aesara_code_(expr)
  
      # Iterate through variables in the Aesara computational graph that the
      # printed expression depends on
      seen = set()
      for v in aesara.graph.basic.ancestors([expr_t]):
          # Owner-less, non-constant variables should be our symbols
          if v.owner is None and not isinstance(
              v, aesara.graph.basic.Constant
          ):
              # Check it corresponds to a symbol and appears only once
              assert v.name in symbol_names
              assert v.name not in seen
              seen.add(v.name)
  
      # Check all were present
      assert seen == symbol_names
  
imports: import logging
  from sympy.external import import_module
  from sympy.testing.pytest import raises, SKIP
  from sympy.utilities.exceptions import ignore_warnings
  import sympy
  from sympy.core.singleton import S
  from sympy.abc import x, y, z, t
  from sympy.printing.aesaracode import aesara_code, dim_handling, aesara_function
label_desc: Use image node_id 41 for calling a global function with example usage: test_cache_complex() without return types