code: def local_useless_unbatched_blockwise(fgraph, node):
      """Remove Blockwise that don't have any batched dims."""
      op = node.op
      inputs = node.inputs
  
      batch_ndims = node.op.batch_ndim(node)
      if all(
          all(inp.type.broadcastable[:batch_ndims]) for inp in inputs
      ):
          if batch_ndims:
              # Remove dummy batch dims
              axis = tuple(range(batch_ndims))
              inputs = [inp.squeeze(axis) for inp in inputs]
          new_outs = op.core_op.make_node(*inputs).outputs
          if batch_ndims:
              # Reintroduce dummy batch dims
              new_outs = [
                  shape_padleft(out, batch_ndims) for out in new_outs
              ]
          return copy_stack_trace(node.outputs, new_outs)
  
file_path: pytensor/pytensor/tensor/rewriting/blockwise.py
imports: from typing import Optional
  from pytensor.compile.mode import optdb
  from pytensor.graph import Constant, node_rewriter
  from pytensor.graph.replace import vectorize_node
  from pytensor.graph.rewriting.basic import copy_stack_trace, out2in
  from pytensor.tensor.basic import Alloc, ARange, alloc, shape_padleft
  from pytensor.tensor.blockwise import Blockwise
  from pytensor.tensor.math import Dot
  from pytensor.tensor.rewriting.basic import register_canonicalize, register_specialize, register_stabilize
  from pytensor.tensor.subtensor import AdvancedIncSubtensor, AdvancedSubtensor, Subtensor
label_desc: Use image node_id 2 for calling a global function with example usage: local_useless_unbatched_blockwise(fgraph, node) and returns: copy_stack_trace