code: def local_det_chol(fgraph, node):
      """
      If we have det(X) and there is already an L=cholesky(X)
      floating around, then we can use prod(diag(L)) to get the determinant.
  
      """
      (x,) = node.inputs
      for cl, xpos in fgraph.clients[x]:
          if cl == "output":
              continue
          if isinstance(cl.op, Blockwise) and isinstance(
              cl.op.core_op, Cholesky
          ):
              L = cl.outputs[0]
              return [
                  prod(diagonal(L, axis1=-2, axis2=-1) ** 2, axis=-1)
              ]
  
imports: import logging
  from typing import cast
  from pytensor.graph.rewriting.basic import copy_stack_trace, node_rewriter
  from pytensor.tensor.basic import TensorVariable, diagonal, swapaxes
  from pytensor.tensor.blas import Dot22
  from pytensor.tensor.blockwise import Blockwise
  from pytensor.tensor.elemwise import DimShuffle
  from pytensor.tensor.math import Dot, Prod, _matrix_matrix_matmul, log, prod
  from pytensor.tensor.nlinalg import MatrixInverse, det
  from pytensor.tensor.rewriting.basic import register_canonicalize, register_specialize, register_stabilize
  from pytensor.tensor.slinalg import Cholesky, Solve, SolveBase, cholesky, solve, solve_triangular
label_desc: Use image node_id 10 for calling a global function with example usage: local_det_chol(fgraph, node) and returns: list