code: def local_alloc_dimshuffle(fgraph, node):
      """
      If a dimshuffle is inside an alloc and only adds dimension to the
      left, remove it.
  
      Alloc(DimShuffle(x), ...) - > Alloc(x, ...)
      """
      if isinstance(node.op, Alloc):
          input_ = node.inputs[0]
          if input_.owner and isinstance(input_.owner.op, DimShuffle):
              # check if it only adds dimension to the left
              new_order = input_.owner.op.new_order
              expected_new_order = ("x",) * (
                  input_.ndim - input_.owner.inputs[0].ndim
              ) + tuple(range(input_.owner.inputs[0].ndim))
              if new_order != expected_new_order:
                  return False
              return [alloc(input_.owner.inputs[0], *node.inputs[1:])]
      return False
  
file_path: pytensor/pytensor/tensor/rewriting/uncanonicalize.py
imports: from pytensor import scalar
  from pytensor.graph.rewriting.basic import copy_stack_trace, node_rewriter
  from pytensor.tensor.basic import Alloc, alloc, constant
  from pytensor.tensor.elemwise import CAReduce, DimShuffle
  from pytensor.tensor.math import Argmax, Max, MaxAndArgmax, Min, neg
  from pytensor.tensor.rewriting.basic import register_uncanonicalize
  from pytensor.tensor.shape import Reshape, reshape
  from pytensor.tensor.subtensor import Subtensor
label_desc: Use image node_id 3 for calling a global function with example usage: local_alloc_dimshuffle(fgraph, node) and returns: False, list, False