code: def test_batched_mvnormal_logp_and_dlogp(
      mu_batch_shape, cov_batch_shape, benchmark
  ):
      rng = np.random.default_rng(sum(map(ord, "batched_mvnormal")))
  
      value_batch_shape = mu_batch_shape
      if len(cov_batch_shape) > len(mu_batch_shape):
          value_batch_shape = cov_batch_shape
  
      value = tensor("value", shape=(*value_batch_shape, 10))
      mu = tensor("mu", shape=(*mu_batch_shape, 10))
      cov = tensor("cov", shape=(*cov_batch_shape, 10, 10))
  
      test_values = [
          rng.normal(size=value.type.shape),
          rng.normal(size=mu.type.shape),
          np.eye(cov.type.shape[-1])
          * np.abs(rng.normal(size=cov.type.shape)),
      ]
  
      chol_cov = cholesky(cov, lower=True, on_error="raise")
      delta_trans = solve_triangular(chol_cov, value - mu, b_ndim=1)
      quaddist = (delta_trans**2).sum(axis=-1)
      diag = diagonal(chol_cov, axis1=-2, axis2=-1)
      logdet = log(diag).sum(axis=-1)
      k = value.shape[-1]
      norm = -0.5 * k * (np.log(2 * np.pi))
  
      logp = norm - 0.5 * quaddist - logdet
      dlogp = grad(logp.sum(), wrt=[value, mu, cov])
  
      fn = pytensor.function([value, mu, cov], [logp, *dlogp])
      benchmark(fn, *test_values)
  
imports: import re
  from itertools import product
  from typing import Optional, Union
  import numpy
  import pytest
  import pytensor
  from pytensor import config, function
  from pytensor.compile import get_mode
  from pytensor.gradient import grad
  from pytensor.graph import Apply, Op
  from pytensor.graph.replace import vectorize_node
  from pytensor.raise_op import assert_op
  from pytensor.tensor import diagonal, log, tensor
  from pytensor.tensor.blockwise import Blockwise, vectorize_node_fallback
  from pytensor.tensor.nlinalg import MatrixInverse
  from pytensor.tensor.rewriting.blas import specialize_matmul_to_batched_dot
  from pytensor.tensor.slinalg import Cholesky, Solve, cholesky, solve_triangular
  from pytensor.tensor.utils import _parse_gufunc_signature
label_desc: Use image node_id 7 for calling a global function with example usage: test_batched_mvnormal_logp_and_dlogp(mu_batch_shape, cov_batch_shape, benchmark) without return types