code: def _get_fns_in_eigenbasis(
      k_train_train: jnp.ndarray,
      diag_reg: float,
      diag_reg_absolute_scale: bool,
      fns: Iterable[Callable[[jnp.ndarray, jnp.ndarray], jnp.ndarray]],
  ) -> Generator[
      Callable[[jnp.ndarray, jnp.ndarray], jnp.ndarray], None, None
  ]:
      """Build functions of a matrix in its eigenbasis.
  
      Args:
        k_train_train:
          an n x n matrix.
  
        diag_reg:
          diagonal regularizer strength.
  
        diag_reg_absolute_scale:
          `True` to use absolute (vs relative to mean trace) regularization.
  
        fns:
          a sequence of functions that act on the eigenvalues (evals, dt) ->
          modified_evals.
  
      Returns:
        A tuple of functions that act as functions of the matrix mat
        acting on vectors: `transform(vec, dt) = fn(mat, dt) @ vec`
      """
      k_train_train = utils.make_2d(k_train_train)
      k_train_train = _add_diagonal_regularizer(
          k_train_train, diag_reg, diag_reg_absolute_scale
      )
      evals, evecs = jnp.linalg.eigh(k_train_train)
      evals = jnp.expand_dims(evals, 0)
  
      def to_eigenbasis(fn):
          """Generates a transform given a function on the eigenvalues."""
  
          def new_fn(y_train, t):
              return jnp.einsum(
                  "ji,ti,ki,k...->tj...",
                  evecs,
                  fn(evals, t),
                  evecs,
                  y_train,
                  optimize=_optimize(),
              )
  
          return new_fn
  
      return (to_eigenbasis(fn) for fn in fns)
  
imports: import collections
  from functools import lru_cache
  from typing import Any, Callable, Generator, Iterable, NamedTuple, Optional, Protocol, Union
  import jax
  from jax import grad
  from jax.experimental import ode
  import jax.numpy
  import jax.scipy
  from jax.tree_util import tree_all
  from jax.tree_util import tree_map
  import numpy
  import scipy
  from .utils import dataclasses
  from .utils import utils
  from .utils.typing import Axes
  from .utils.typing import Get
  from .utils.typing import KernelFn
label_desc: Use image node_id 8 for calling a global function with example usage: _get_fns_in_eigenbasis(k_train_train, diag_reg, diag_reg_absolute_scale, fns) and returns: unknown, new_fn, jnp