code: def test_expand_packed_triangular():
      with pytest.raises(ValueError):
          x = pt.matrix("x")
          x.tag.test_value = np.array(
              [[1.0]], dtype=pytensor.config.floatX
          )
          expand_packed_triangular(5, x)
      N = 5
      packed = pt.vector("packed")
      packed.tag.test_value = floatX(np.zeros(N * (N + 1) // 2))
      with pytest.raises(TypeError):
          expand_packed_triangular(packed.shape[0], packed)
      np.random.seed(42)
      vals = np.random.randn(N, N)
      lower = floatX(np.tril(vals))
      lower_packed = floatX(vals[lower != 0])
      upper = floatX(np.triu(vals))
      upper_packed = floatX(vals[upper != 0])
      expand_lower = expand_packed_triangular(N, packed, lower=True)
      expand_upper = expand_packed_triangular(N, packed, lower=False)
      expand_diag_lower = expand_packed_triangular(
          N, packed, lower=True, diagonal_only=True
      )
      expand_diag_upper = expand_packed_triangular(
          N, packed, lower=False, diagonal_only=True
      )
      assert np.all(expand_lower.eval({packed: lower_packed}) == lower)
      assert np.all(expand_upper.eval({packed: upper_packed}) == upper)
      assert np.all(
          expand_diag_lower.eval({packed: lower_packed})
          == floatX(np.diag(vals))
      )
      assert np.all(
          expand_diag_upper.eval({packed: upper_packed})
          == floatX(np.diag(vals))
      )
  
imports: import warnings
  import numpy
  import numpy.testing
  import pytensor
  import pytensor.tensor
  import pytest
  from pymc.math import LogDet, cartesian, expand_packed_triangular, invprobit, kron_dot, kron_solve_lower, kronecker, log1mexp, log1mexp_numpy, logdet, logdiffexp, logdiffexp_numpy, probit
  from pymc.pytensorf import floatX
  from tests.helpers import verify_grad
label_desc: Use image node_id 12 for calling a global function with example usage: test_expand_packed_triangular() without return types