class_docstr: Symbolic operator representing the sum of operators.
  
  Args:
      *summands (tuple[~.operation.Operator]): a tuple of operators which will be summed together.
  
  Keyword Args:
      id (str or None): id for the sum operator. Default is None.
  
  .. note::
      Currently this operator can not be queued in a circuit as an operation, only measured terminally.
  
  .. note::
  
      This operator supports batched operands:
      >>> op = qml.sum(qml.RX(np.array([1, 2, 3]), wires=0), qml.PauliX(1))
      >>> op.matrix().shape
      (3, 4, 4)
  
      But it doesn't support batching of operators:
      >>> op = qml.sum(np.array([qml.RX(0.4, 0), qml.RZ(0.3, 0)]), qml.PauliZ(0))
      AttributeError: 'numpy.ndarray' object has no attribute 'wires'
  
  .. seealso:: :func:`~.ops.op_math.sum`
  
  **Example**
  
  >>> summed_op = Sum(qml.PauliX(0), qml.PauliZ(0))
  >>> summed_op
  PauliX(wires=[0]) + PauliZ(wires=[0])
  >>> qml.matrix(summed_op)
  array([[ 1,  1],
         [ 1, -1]])
  >>> summed_op.terms()
  ([1.0, 1.0], (PauliX(wires=[0]), PauliZ(wires=[0])))
  
  .. details::
      :title: Usage Details
  
      We can combine parameterized operators, and support sums between operators acting on
      different wires.
  
      >>> summed_op = Sum(qml.RZ(1.23, wires=0), qml.Identity(wires=1))
      >>> summed_op.matrix()
      array([[1.81677345-0.57695852j, 0.        +0.j        ,
              0.        +0.j        , 0.        +0.j        ],
             [0.        +0.j        , 1.81677345-0.57695852j,
              0.        +0.j        , 0.        +0.j        ],
             [0.        +0.j        , 0.        +0.j        ,
              1.81677345+0.57695852j, 0.        +0.j        ],
             [0.        +0.j        , 0.        +0.j        ,
              0.        +0.j        , 1.81677345+0.57695852j]])
  
      The Sum operation can also be measured inside a qnode as an observable.
      If the circuit is parameterized, then we can also differentiate through the
      sum observable.
  
      .. code-block:: python
  
          sum_op = Sum(qml.PauliX(0), qml.PauliZ(1))
          dev = qml.device("default.qubit", wires=2)
  
          @qml.qnode(dev, diff_method="best")
          def circuit(weights):
              qml.RX(weights[0], wires=0)
              qml.RY(weights[1], wires=1)
              qml.CNOT(wires=[0, 1])
              qml.RX(weights[2], wires=1)
              return qml.expval(sum_op)
  
      >>> weights = qnp.array([0.1, 0.2, 0.3], requires_grad=True)
      >>> qml.grad(circuit)(weights)
      array([-0.09347337, -0.18884787, -0.28818254])
docstr: Representation of the operator as a matrix in the computational basis.
  
  If ``wire_order`` is provided, the numerical representation considers the position of the
  operator's wires in the global wire order. Otherwise, the wire order defaults to the
  operator's wires.
  
  If the matrix depends on trainable parameters, the result
  will be cast in the same autodifferentiation framework as the parameters.
  
  A ``MatrixUndefinedError`` is raised if the matrix representation has not been defined.
  
  .. seealso:: :meth:`~.Operator.compute_matrix`
  
  Args:
      wire_order (Iterable): global wire order, must contain all wire labels from the
      operator's wires
  
  Returns:
      tensor_like: matrix representation
docstr_tok: ["Representation","of","the","operator","as","a","matrix","in","the","computational","basis",".","If","``","wire_order","``","is","provided",",","the","numerical","representation","considers","the","position","of","the","operator","'s","wires","in","the","global","wire","order",".","Otherwise",",","the","wire","order","defaults","to","the","operator","'s","wires",".","If","the","matrix","depends","on","trainable","parameters",",","the","result","will","be","cast","in","the","same","autodifferentiation","framework","as","the","parameters",".","A","``","MatrixUndefinedError","``","is","raised","if","the","matrix","representation","has","not","been","defined",".","..","seealso",":",":",":","meth",":","`","~.Operator.compute_matrix","`","Args",":","wire_order","(","Iterable",")",":","global","wire","order",",","must","contain","all","wire","labels","from","the","operator","'s","wires","Returns",":","tensor_like",":","matrix","representation"]
code: def matrix(self, wire_order=None):
      r"""Representation of the operator as a matrix in the computational basis.
  
      If ``wire_order`` is provided, the numerical representation considers the position of the
      operator's wires in the global wire order. Otherwise, the wire order defaults to the
      operator's wires.
  
      If the matrix depends on trainable parameters, the result
      will be cast in the same autodifferentiation framework as the parameters.
  
      A ``MatrixUndefinedError`` is raised if the matrix representation has not been defined.
  
      .. seealso:: :meth:`~.Operator.compute_matrix`
  
      Args:
          wire_order (Iterable): global wire order, must contain all wire labels from the
          operator's wires
  
      Returns:
          tensor_like: matrix representation
      """
      gen = (
          (
              qml.matrix(op)
              if isinstance(op, Hamiltonian)
              else op.matrix(),
              op.wires,
          )
          for op in self
      )
  
      reduced_mat, sum_wires = math.reduce_matrices(
          gen, reduce_func=math.add
      )
  
      wire_order = wire_order or self.wires
  
      return math.expand_matrix(
          reduced_mat, sum_wires, wire_order=wire_order
      )
  
imports: import itertools
  from copy import copy
  from typing import List
  import numpy
  import pennylane
  from pennylane import math
  from pennylane.operation import Operator
  from pennylane.ops.qubit import Hamiltonian
  from pennylane.queuing import QueuingManager
  from .composite import CompositeOp
label_desc: Use image node_id 4 for calling the Sum obj's underlying member method code with example usage: obj.matrix(wire_order) and returns: math