code: def test_specify_shape_logprob():
      # 1. Create graph using SpecifyShape
      # Use symbolic last dimension, so that SpecifyShape is not useless
      last_dim = pt.scalar(name="last_dim", dtype="int64")
      x_base = Dirichlet.dist(pt.ones((last_dim,)), shape=(5, last_dim))
      x_base.name = "x"
      x_rv = pt.specify_shape(x_base, shape=(5, 3))
      x_rv.name = "x"
  
      # 2. Request logp
      x_vv = x_rv.clone()
      [x_logp] = conditional_logp({x_rv: x_vv}).values()
  
      # 3. Test logp
      x_logp_fn = pytensor.function([last_dim, x_vv], x_logp)
  
      # 3.1 Test valid logp
      x_vv_test = stats.dirichlet(np.ones((3,))).rvs(size=(5,))
      np.testing.assert_array_almost_equal(
          x_logp_fn(last_dim=3, x=x_vv_test),
          dirichlet_logpdf(x_vv_test, np.ones((3,))),
      )
  
      # 3.2 Test shape error
      x_vv_test_invalid = stats.dirichlet(np.ones((1,))).rvs(size=(5,))
      with pytest.raises(
          TypeError,
          match=re.escape("not compatible with the data's ((5, 1))"),
      ):
          x_logp_fn(last_dim=1, x=x_vv_test_invalid)
  
file_path: pymc/tests/logprob/test_checks.py
imports: import re
  import numpy
  import pytensor
  import pytensor.tensor
  import pytest
  from pytensor.raise_op import Assert
  from scipy import stats
  from pymc.distributions import Dirichlet
  from pymc.logprob.basic import conditional_logp
  from tests.distributions.test_multivariate import dirichlet_logpdf
label_desc: Use image node_id 1 for calling a global function with example usage: test_specify_shape_logprob() without return types