code: def test_measurable_dimshuffle(ds_order, multivariate):
      if multivariate:
          base_rv = pt.random.dirichlet([1, 2, 3], size=(2, 1))
      else:
          base_rv = pt.exp(pt.random.beta(1, 2, size=(2, 1, 3)))
  
      ds_rv = base_rv.dimshuffle(ds_order)
      base_vv = base_rv.clone()
      ds_vv = ds_rv.clone()
  
      # Remove support dimension axis from ds_order (i.e., 2, for multivariate)
      if multivariate:
          logp_ds_order = [o for o in ds_order if o == "x" or o < 2]
      else:
          logp_ds_order = ds_order
  
      ref_logp = logp(base_rv, base_vv).dimshuffle(logp_ds_order)
  
      # Disable local_dimshuffle_rv_lift to test fallback Aeppl rewrite
      ir_rewriter = logprob_rewrites_db.query(
          RewriteDatabaseQuery(include=["basic"]).excluding(
              "dimshuffle_lift"
          )
      )
      ds_logp = conditional_logp(
          {ds_rv: ds_vv}, ir_rewriter=ir_rewriter
      )
      ds_logp_combined = pt.add(*ds_logp.values())
      assert ds_logp_combined is not None
  
      ref_logp_fn = pytensor.function([base_vv], ref_logp)
      ds_logp_fn = pytensor.function([ds_vv], ds_logp_combined)
  
      base_test_value = base_rv.eval()
      ds_test_value = (
          pt.constant(base_test_value).dimshuffle(ds_order).eval()
      )
  
      np.testing.assert_array_equal(
          ref_logp_fn(base_test_value), ds_logp_fn(ds_test_value)
      )
  
imports: import numpy
  import pytensor
  import pytest
  from pytensor import tensor
  from pytensor.graph import RewriteDatabaseQuery
  from pytensor.graph.rewriting.basic import in2out
  from pytensor.graph.rewriting.utils import rewrite_graph
  from pytensor.tensor.basic import Alloc
  from scipy import stats
  from pymc.logprob.basic import conditional_logp, logp
  from pymc.logprob.rewriting import logprob_rewrites_db
  from pymc.logprob.tensor import naive_bcast_rv_lift
  from pymc.testing import assert_no_rvs
label_desc: Use image node_id 10 for calling a global function with example usage: test_measurable_dimshuffle(ds_order, multivariate) without return types