code: def test_CRootOf_lazy():
      # irreducible poly with both real and complex roots:
      f = Poly(x**3 + 2 * x + 2)
  
      # real root:
      CRootOf.clear_cache()
      r = CRootOf(f, 0)
      # Not yet in cache, after construction:
      assert r.poly not in rootoftools._reals_cache
      assert r.poly not in rootoftools._complexes_cache
      r.evalf()
      # In cache after evaluation:
      assert r.poly in rootoftools._reals_cache
      assert r.poly not in rootoftools._complexes_cache
  
      # complex root:
      CRootOf.clear_cache()
      r = CRootOf(f, 1)
      # Not yet in cache, after construction:
      assert r.poly not in rootoftools._reals_cache
      assert r.poly not in rootoftools._complexes_cache
      r.evalf()
      # In cache after evaluation:
      assert r.poly in rootoftools._reals_cache
      assert r.poly in rootoftools._complexes_cache
  
      # composite poly with both real and complex roots:
      f = Poly((x**2 - 2) * (x**2 + 1))
  
      # real root:
      CRootOf.clear_cache()
      r = CRootOf(f, 0)
      # In cache immediately after construction:
      assert r.poly in rootoftools._reals_cache
      assert r.poly not in rootoftools._complexes_cache
  
      # complex root:
      CRootOf.clear_cache()
      r = CRootOf(f, 2)
      # In cache immediately after construction:
      assert r.poly in rootoftools._reals_cache
      assert r.poly in rootoftools._complexes_cache
  
imports: from sympy.polys.polytools import Poly
  import sympy.polys.rootoftools
  from sympy.polys.rootoftools import rootof, RootOf, CRootOf, RootSum, _pure_key_dict
  from sympy.polys.polyerrors import MultivariatePolynomialError, GeneratorsNeeded, PolynomialError
  from sympy.core.function import Function, Lambda
  from sympy.core.numbers import Float, I, Rational
  from sympy.core.relational import Eq
  from sympy.core.singleton import S
  from sympy.functions.elementary.exponential import exp, log
  from sympy.functions.elementary.miscellaneous import sqrt
  from sympy.functions.elementary.trigonometric import tan
  from sympy.integrals.integrals import Integral
  from sympy.polys.orthopolys import legendre_poly
  from sympy.solvers.solvers import solve
  from sympy.testing.pytest import raises, slow
  from sympy.core.expr import unchanged
  from sympy.abc import a, b, x, y, z, r
label_desc: Use image node_id 15 for calling a global function with example usage: test_CRootOf_lazy() without return types