code: def local_dimshuffle_alloc(fgraph, node):
      """
      If an alloc is inside a dimshuffle which only adds dimension to the left,
      scrap the dimshuffle and adds 1 into the alloc
  
      dimshuffle{x, 0, 1}(alloc([3 4], 3, 2) => alloc([3 4], 1, 3, 2)
      """
      if isinstance(node.op, DimShuffle) and node.inputs[0].owner:
          input_ = node.inputs[0]
          if isinstance(input_.owner.op, Alloc):
              # check if it only adds dimension to the left
              new_order = node.op.new_order
              expected_new_order = ("x",) * (
                  len(new_order) - input_.ndim
              ) + tuple(range(input_.ndim))
              if new_order != expected_new_order:
                  return False
  
              # count numbers of 'x'
              nb_new_dims = len(new_order) - input_.ndim
              new_shape_input = (1,) * nb_new_dims + tuple(
                  input_.owner.inputs[1:]
              )
  
              return [alloc(input_.owner.inputs[0], *new_shape_input)]
      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 5 for calling a global function with example usage: local_dimshuffle_alloc(fgraph, node) and returns: False, list, False