code: def logprob_dimshuffle(op, values, base_var, **kwargs):
      """Compute the log-likelihood graph for a `MeasurableDimShuffle`."""
      (value,) = values
  
      # Reverse the effects of dimshuffle on the value variable
      # First, drop any augmented dimensions and reinsert any dropped dimensions
      undo_ds: List[Union[int, str]] = [
          i for i, o in enumerate(op.new_order) if o != "x"
      ]
      dropped_dims = tuple(
          sorted(set(op.transposition) - set(op.shuffle))
      )
      for dropped_dim in dropped_dims:
          undo_ds.insert(dropped_dim, "x")
      value = value.dimshuffle(undo_ds)
  
      # Then, unshuffle remaining dims
      original_shuffle = list(op.shuffle)
      for dropped_dim in dropped_dims:
          original_shuffle.insert(dropped_dim, dropped_dim)
      undo_ds = [
          original_shuffle.index(i)
          for i in range(len(original_shuffle))
      ]
      value = value.dimshuffle(undo_ds)
  
      raw_logp = _logprob_helper(base_var, value)
  
      # Re-apply original dimshuffle, ignoring any support dimensions consumed by
      # the logprob function. This assumes that support dimensions are always in
      # the rightmost positions, and all we need to do is to discard the highest
      # indexes in the original dimshuffle order. Otherwise, there is no way of
      # knowing which dimensions were consumed by the logprob function.
      redo_ds = [
          o for o in op.new_order if o == "x" or o < raw_logp.ndim
      ]
      return raw_logp.dimshuffle(redo_ds)
  
imports: from typing import List, Optional, Union
  import pytensor
  from pytensor import tensor
  from pytensor.graph.op import compute_test_value
  from pytensor.graph.rewriting.basic import node_rewriter
  from pytensor.tensor.basic import Alloc, Join, MakeVector
  from pytensor.tensor.elemwise import DimShuffle
  from pytensor.tensor.random.op import RandomVariable
  from pytensor.tensor.random.rewriting import local_dimshuffle_rv_lift, local_rv_size_lift
  from pymc.logprob.abstract import MeasurableVariable, _logprob, _logprob_helper
  from pymc.logprob.rewriting import PreserveRVMappings, assume_measured_ir_outputs, measurable_ir_rewrites_db
  from pymc.logprob.utils import check_potential_measurability, replace_rvs_by_values
  from pymc.pytensorf import constant_fold
label_desc: Use image node_id 5 for calling a global function with example usage: logprob_dimshuffle(op, values, base_var) and returns: raw_logp