code: def _matrix_transform(
      tape: qml.tape.QuantumTape, wire_order=None, **kwargs
  ) -> (Sequence[qml.tape.QuantumTape], Callable):
      if not tape.wires:
          raise qml.operation.MatrixUndefinedError
  
      if wire_order and not set(tape.wires).issubset(wire_order):
          raise OperationTransformError(
              f"Wires in circuit {list(tape.wires)} are inconsistent with "
              f"those in wire_order {list(wire_order)}"
          )
  
      wires = kwargs.get("device_wires", None) or tape.wires
      wire_order = wire_order or wires
  
      def processing_fn(res):
          """Defines how matrix works if applied to a tape containing multiple operations."""
  
          params = res[0].get_parameters(trainable_only=False)
          interface = qml.math.get_interface(*params)
  
          # initialize the unitary matrix
          if len(res[0].operations) == 0:
              result = qml.math.eye(
                  2 ** len(wire_order), like=interface
              )
          else:
              result = matrix(
                  res[0].operations[0], wire_order=wire_order
              )
  
          for op in res[0].operations[1:]:
              U = matrix(op, wire_order=wire_order)
              # Coerce the matrices U and result and use matrix multiplication. Broadcasted axes
              # are handled correctly automatically by ``matmul`` (See e.g. NumPy documentation)
              result = qml.math.matmul(
                  *qml.math.coerce([U, result], like=interface),
                  like=interface,
              )
  
          return result
  
      return [tape], processing_fn
  
file_path: pennylane/pennylane/ops/functions/matrix.py
imports: from typing import Sequence, Callable
  from functools import partial
  from warnings import warn
  import pennylane
  from pennylane.transforms.op_transforms import OperationTransformError
  from pennylane import transform
  from pennylane.typing import TensorLike
label_desc: Use image node_id 2 for calling a global function with example usage: _matrix_transform(tape, wire_order) and returns: list,  processing_fn, result