class_docstr: Developer-facing base class for single-operator symbolic operators that contain a
  scalar coefficient.
  
  Args:
      base (~.operation.Operator): the base operation that is modified symbolicly
      scalar (float): the scalar coefficient
      id (str): custom label given to an operator instance, can be useful for some applications
          where the instance has to be identified
  
  This *developer-facing* class can serve as a parent to single base symbolic operators, such as
  :class:`~.ops.op_math.SProd` and :class:`~.ops.op_math.Pow`.
class_docstr_tok: ["Developer-facing","base","class","for","single-operator","symbolic","operators","that","contain","a","scalar","coefficient",".","Args",":","base","(","~.operation.Operator",")",":","the","base","operation","that","is","modified","symbolicly","scalar","(","float",")",":","the","scalar","coefficient","id","(","str",")",":","custom","label","given","to","an","operator","instance",",","can","be","useful","for","some","applications","where","the","instance","has","to","be","identified","This","*","developer-facing","*","class","can","serve","as","a","parent","to","single","base","symbolic","operators",",","such","as",":","class",":","`","~.ops.op_math.SProd","`","and",":","class",":","`","~.ops.op_math.Pow","`","."]
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 base 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","base","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 base 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
      """
      # compute base matrix
      if isinstance(self.base, qml.Hamiltonian):
          base_matrix = qml.matrix(self.base)
      else:
          base_matrix = self.base.matrix()
  
      scalar_interface = qml.math.get_interface(self.scalar)
      scalar = self.scalar
      if scalar_interface == "torch":
          # otherwise get `RuntimeError: Can't call numpy() on Tensor that requires grad.`
          base_matrix = qml.math.convert_like(base_matrix, self.scalar)
      elif scalar_interface == "tensorflow":
          # just cast everything to complex128. Otherwise we may have casting problems
          # where things get truncated like in SProd(tf.Variable(0.1), qml.PauliX(0))
          scalar = qml.math.cast(scalar, "complex128")
          base_matrix = qml.math.cast(base_matrix, "complex128")
  
      # compute scalar operation on base matrix taking batching into account
      scalar_size = qml.math.size(scalar)
      if scalar_size != 1:
          if scalar_size == self.base.batch_size:
              # both base and scalar are broadcasted
              mat = qml.math.stack(
                  [
                      self._matrix(s, m)
                      for s, m in zip(scalar, base_matrix)
                  ]
              )
          else:
              # only scalar is broadcasted
              mat = qml.math.stack(
                  [self._matrix(s, base_matrix) for s in scalar]
              )
      elif self.base.batch_size is not None:
          # only base is broadcasted
          mat = qml.math.stack(
              [self._matrix(scalar, ar2) for ar2 in base_matrix]
          )
      else:
          # none are broadcasted
          mat = self._matrix(scalar, base_matrix)
  
      return qml.math.expand_matrix(
          mat, wires=self.wires, wire_order=wire_order
      )
  
imports: from abc import abstractmethod
  from copy import copy
  import numpy
  import pennylane
  from pennylane.operation import Operator, _UNSET_BATCH_SIZE
  from pennylane.queuing import QueuingManager
label_desc: Use image node_id 8 for calling the ScalarSymbolicOp obj's underlying member method code with example usage: obj.matrix(wire_order) and returns: qml