code: def local_dimshuffle_rv_lift(fgraph, node):
      """Lift a ``DimShuffle`` through ``RandomVariable`` inputs.
  
      For example, ``normal(mu, std).T == normal(mu.T, std.T)``.
  
      This rewrite is only applicable when the Dimshuffle operation does
      not affect support dimensions.
  
      TODO: Support dimension dropping
      """
  
      ds_op = node.op
  
      if not isinstance(ds_op, DimShuffle):
          return False
  
      base_rv = node.inputs[0]
      rv_node = base_rv.owner
  
      if not (rv_node and isinstance(rv_node.op, RandomVariable)):
          return False
  
      # Dimshuffle which drop dimensions not supported yet
      if ds_op.drop:
          return False
  
      rv_op = rv_node.op
      rng, size, dtype, *dist_params = rv_node.inputs
      rv = rv_node.default_output()
  
      # Check that Dimshuffle does not affect support dims
      supp_dims = set(range(rv.ndim - rv_op.ndim_supp, rv.ndim))
      shuffled_dims = {
          dim for i, dim in enumerate(ds_op.shuffle) if dim != i
      }
      augmented_dims = {d - rv_op.ndim_supp for d in ds_op.augment}
      if (shuffled_dims | augmented_dims) & supp_dims:
          return False
  
      # If no one else is using the underlying RandomVariable, then we can
      # do this; otherwise, the graph would be internally inconsistent.
      if is_rv_used_in_graph(base_rv, node, fgraph):
          return False
  
      batched_dims = rv.ndim - rv_op.ndim_supp
      batched_dims_ds_order = tuple(
          o for o in ds_op.new_order if o not in supp_dims
      )
  
      # Make size explicit
      missing_size_dims = batched_dims - get_vector_length(size)
      if missing_size_dims > 0:
          full_size = tuple(
              broadcast_params(dist_params, rv_op.ndims_params)[0].shape
          )
          size = full_size[:missing_size_dims] + tuple(size)
  
      # Update the size to reflect the DimShuffled dimensions
      new_size = [
          constant(1, dtype="int64") if o == "x" else size[o]
          for o in batched_dims_ds_order
      ]
  
      # Updates the params to reflect the Dimshuffled dimensions
      new_dist_params = []
      for param, param_ndim_supp in zip(
          dist_params, rv_op.ndims_params
      ):
          # Add broadcastable dimensions to the parameters that would have been expanded by the size
          padleft = batched_dims - (param.ndim - param_ndim_supp)
          if padleft > 0:
              param = shape_padleft(param, padleft)
  
          # Add the parameter support dimension indexes to the batched dimensions Dimshuffle
          param_new_order = batched_dims_ds_order + tuple(
              range(batched_dims, batched_dims + param_ndim_supp)
          )
          new_dist_params.append(param.dimshuffle(param_new_order))
  
      new_node = rv_op.make_node(rng, new_size, dtype, *new_dist_params)
  
      if config.compute_test_value != "off":
          compute_test_value(new_node)
  
      out = new_node.outputs[1]
      if base_rv.name:
          out.name = f"{base_rv.name}_lifted"
      return [out]
  
imports: from itertools import chain
  from pytensor.compile import optdb
  from pytensor.configdefaults import config
  from pytensor.graph import ancestors
  from pytensor.graph.op import compute_test_value
  from pytensor.graph.rewriting.basic import copy_stack_trace, in2out, node_rewriter
  from pytensor.scalar import integer_types
  from pytensor.tensor import NoneConst
  from pytensor.tensor.basic import constant, get_vector_length
  from pytensor.tensor.elemwise import DimShuffle
  from pytensor.tensor.extra_ops import broadcast_to
  from pytensor.tensor.random.op import RandomVariable
  from pytensor.tensor.random.utils import broadcast_params
  from pytensor.tensor.shape import Shape, Shape_i, shape_padleft
  from pytensor.tensor.subtensor import AdvancedSubtensor, AdvancedSubtensor1, Subtensor, as_index_variable, get_idx_list
  from pytensor.tensor.type_other import SliceType
label_desc: Use image node_id 4 for calling a global function with example usage: local_dimshuffle_rv_lift(fgraph, node) and returns: list, False, False, False, False, False