code: def vectorize_check_and_raise(op, node, batch_x, batch_cond):
      from pytensor.tensor.extra_ops import broadcast_arrays
      from pytensor.tensor.shape import shape_padright
  
      batch_cond_dims = batch_cond.type.ndim
  
      if batch_cond_dims:
          out = op(batch_x, batch_cond.all())
          # Condition may broadcast batch dims of x
          # We broadcast after the Check Op, so it can be removed more easily if not needed
          x_core_ndim = node.inputs[0].type.ndim
          batch_out, _ = broadcast_arrays(
              out, shape_padright(batch_cond, x_core_ndim)
          )
          return batch_out.owner
      else:
          return op.make_node(batch_x, batch_cond)
  
imports: from textwrap import indent
  import numpy
  from pytensor.gradient import DisconnectedType
  from pytensor.graph.basic import Apply, Variable
  from pytensor.graph.replace import _vectorize_node
  from pytensor.link.c.op import COp
  from pytensor.link.c.params_type import ParamsType
  from pytensor.link.c.type import Generic
  from pytensor.scalar.basic import ScalarType
  from pytensor.tensor.type import DenseTensorType
label_desc: Use image node_id 1 for calling a global function with example usage: vectorize_check_and_raise(op, node, batch_x, batch_cond) and returns: batch_out, op