code: def test_cholesky_ldotlt(tag, cholesky_form, product, op):
      transform_removes_chol = tag is not None and product == tag
      transform_transposes = (
          transform_removes_chol and cholesky_form != tag
      )
  
      ndim = 2 if op == dot else 3
      A = tensor("L", shape=(None,) * ndim)
      if tag:
          setattr(A.tag, tag + "_triangular", True)
  
      if product == "lower":
          M = op(A, swapaxes(A, -1, -2))
      elif product == "upper":
          M = op(swapaxes(A, -1, -2), A)
      else:
          M = A
  
      C = cholesky(M, lower=(cholesky_form == "lower"))
      f = pytensor.function(
          [A], C, mode=get_default_mode().including("cholesky_ldotlt")
      )
  
      no_cholesky_in_graph = not any(
          isinstance(node.op, Cholesky)
          or (
              isinstance(node.op, Blockwise)
              and isinstance(node.op.core_op, Cholesky)
          )
          for node in f.maker.fgraph.apply_nodes
      )
  
      assert no_cholesky_in_graph == transform_removes_chol
  
      if transform_transposes:
          expected_order = (1, 0) if ndim == 2 else (0, 2, 1)
          assert any(
              isinstance(node.op, DimShuffle)
              and node.op.new_order == expected_order
              for node in f.maker.fgraph.apply_nodes
          )
  
      # Test some concrete value through f
      # there must be lower triangular (f assumes they are)
      Avs = [
          np.eye(1, dtype=pytensor.config.floatX),
          np.eye(10, dtype=pytensor.config.floatX),
          np.array([[2, 0], [1, 4]], dtype=pytensor.config.floatX),
      ]
      if not tag:
          # these must be positive def
          Avs.extend(
              [
                  np.ones((4, 4), dtype=pytensor.config.floatX)
                  + np.eye(4, dtype=pytensor.config.floatX),
              ]
          )
  
      cholesky_vect_fn = np.vectorize(
          partial(
              scipy.linalg.cholesky, lower=(cholesky_form == "lower")
          ),
          signature="(a, a)->(a, a)",
      )
  
      for Av in Avs:
          if tag == "upper":
              Av = Av.T
  
          if product == "lower":
              Mv = Av.dot(Av.T)
          elif product == "upper":
              Mv = Av.T.dot(Av)
          else:
              Mv = Av
  
          if ndim == 3:
              Av = np.broadcast_to(Av, (5, *Av.shape))
              Mv = np.broadcast_to(Mv, (5, *Mv.shape))
  
          np.testing.assert_allclose(
              cholesky_vect_fn(Mv),
              f(Av),
          )
  
imports: from functools import partial
  import numpy
  import pytest
  import scipy.linalg
  from numpy.testing import assert_allclose
  import pytensor
  from pytensor import function
  from pytensor import tensor
  from pytensor.compile import get_default_mode
  from pytensor.configdefaults import config
  from pytensor.tensor import swapaxes
  from pytensor.tensor.blockwise import Blockwise
  from pytensor.tensor.elemwise import DimShuffle
  from pytensor.tensor.math import _allclose, dot, matmul
  from pytensor.tensor.nlinalg import Det, MatrixInverse, matrix_inverse
  from pytensor.tensor.rewriting.linalg import inv_as_solve
  from pytensor.tensor.slinalg import Cholesky, Solve, SolveBase, SolveTriangular, cho_solve, cholesky, solve, solve_triangular
  from pytensor.tensor.type import dmatrix, matrix, tensor, vector
  from tests import unittest_tools
  from tests.test_rop import break_op
label_desc: Use image node_id 5 for calling a global function with example usage: test_cholesky_ldotlt(tag, cholesky_form, product, op) without return types