code: def _cached_roots_legendre(n):
      """
      Cache roots_legendre results to speed up calls of the fixed_quad
      function.
      """
      if n in _cached_roots_legendre.cache:
          return _cached_roots_legendre.cache[n]
  
      _cached_roots_legendre.cache[n] = roots_legendre(n)
      return _cached_roots_legendre.cache[n]
  
imports: from __future__ import annotations
  from typing import TYPE_CHECKING, Callable, Dict, Tuple, Any, cast
  import functools
  import numpy
  import math
  import types
  import warnings
  from numpy import trapz
  from scipy.special import roots_legendre
  from scipy.special import gammaln
label_desc: Use image node_id 4 for calling a global function with example usage: _cached_roots_legendre(n) and returns: _cached_roots_legendre, _cached_roots_legendre