class_docstr: Dictionary representing a linear combination of Pauli words, with the keys
  as :class:`~pennylane.pauli.PauliWord` instances and the values correspond to coefficients.
  
  .. note::
  
      An empty :class:`~.PauliSentence` will be treated as the additive
      identity (i.e 0 * Identity on all wires).
  
  **Examples**
  
  >>> ps = PauliSentence({
          PauliWord({0:'X', 1:'Y'}): 1.23,
          PauliWord({2:'Z', 0:'Y'}): -0.45j
      })
  >>> ps
  1.23 * X(0) @ Y(1)
  + (-0-0.45j) * Z(2) @ Y(0)
  
  Combining Pauli words automatically results in Pauli sentences that can be used to construct more complicated operators.
  
  >>> w1 = PauliWord({0:"X", 1:"Y"})
  >>> w2 = PauliWord({1:"X", 2:"Z"})
  >>> ps = 0.5 * w1 - 1.5 * w2 + 2
  >>> ps + PauliWord({3:"Z"}) - 1
  0.5 * X(0) @ Y(1)
  + -1.5 * X(1) @ Z(2)
  + 1 * I
  + 1.0 * Z(3)
class_docstr_tok: ["Dictionary","representing","a","linear","combination","of","Pauli","words",",","with","the","keys","as",":","class",":","`","~pennylane.pauli.PauliWord","`","instances","and","the","values","correspond","to","coefficients",".","..","note",":",":","An","empty",":","class",":","`","~.PauliSentence","`","will","be","treated","as","the","additive","identity","(","i.e","0","*","Identity","on","all","wires",")",".","*","*","Examples","*","*",">",">",">","ps","=","PauliSentence","(","{","PauliWord","(","{","0",":","'","X","'",",","1",":","'","Y","'","}",")",":","1.23",",","PauliWord","(","{","2",":","'","Z","'",",","0",":","'","Y","'","}",")",":","-0.45j","}",")",">",">",">","ps","1.23","*","X","(","0",")","@","Y","(","1",")","+","(","-0-0.45j",")","*","Z","(","2",")","@","Y","(","0",")","Combining","Pauli","words","automatically","results","in","Pauli","sentences","that","can","be","used","to","construct","more","complicated","operators",".",">",">",">","w1","=","PauliWord","(","{","0",":","''","X","''",",","1",":","''","Y","''","}",")",">",">",">","w2","=","PauliWord","(","{","1",":","''","X","''",",","2",":","''","Z","''","}",")",">",">",">","ps","=","0.5","*","w1","-","1.5","*","w2","+","2",">",">",">","ps","+","PauliWord","(","{","3",":","''","Z","''","}",")","-","1","0.5","*","X","(","0",")","@","Y","(","1",")","+","-1.5","*","X","(","1",")","@","Z","(","2",")","+","1","*","I","+","1.0","*","Z","(","3",")"]
docstr: Returns the matrix representation.
  
  Keyword Args:
      wire_order (iterable or None): The order of qubits in the tensor product.
      format (str): The format of the matrix. It is "dense" by default. Use "csr" for sparse.
      buffer_size (int or None): The maximum allowed memory in bytes to store intermediate results
          in the calculation of sparse matrices. It defaults to ``2 ** 30`` bytes that make
          1GB of memory. In general, larger buffers allow faster computations.
  
  Returns:
      (Union[NumpyArray, ScipySparseArray]): Matrix representation of the Pauli sentence.
  
  Raises:
      ValueError: Can't get the matrix of an empty PauliSentence.
docstr_tok: ["Returns","the","matrix","representation",".","Keyword","Args",":","wire_order","(","iterable","or","None",")",":","The","order","of","qubits","in","the","tensor","product",".","format","(","str",")",":","The","format","of","the","matrix",".","It","is","``","dense","''","by","default",".","Use","``","csr","''","for","sparse",".","buffer_size","(","int","or","None",")",":","The","maximum","allowed","memory","in","bytes","to","store","intermediate","results","in","the","calculation","of","sparse","matrices",".","It","defaults","to","``","2","*","*","30","``","bytes","that","make","1GB","of","memory",".","In","general",",","larger","buffers","allow","faster","computations",".","Returns",":","(","Union","[","NumpyArray",",","ScipySparseArray","]",")",":","Matrix","representation","of","the","Pauli","sentence",".","Raises",":","ValueError",":","Ca","n't","get","the","matrix","of","an","empty","PauliSentence","."]
code: def to_mat(self, wire_order=None, format="dense", buffer_size=None):
      """Returns the matrix representation.
  
      Keyword Args:
          wire_order (iterable or None): The order of qubits in the tensor product.
          format (str): The format of the matrix. It is "dense" by default. Use "csr" for sparse.
          buffer_size (int or None): The maximum allowed memory in bytes to store intermediate results
              in the calculation of sparse matrices. It defaults to ``2 ** 30`` bytes that make
              1GB of memory. In general, larger buffers allow faster computations.
  
      Returns:
          (Union[NumpyArray, ScipySparseArray]): Matrix representation of the Pauli sentence.
  
      Raises:
          ValueError: Can't get the matrix of an empty PauliSentence.
      """
      wire_order = (
          self.wires if wire_order is None else Wires(wire_order)
      )
      if not wire_order.contains_wires(self.wires):
          raise ValueError(
              "Can't get the matrix for the specified wire order because it "
              f"does not contain all the Pauli sentence's wires {self.wires}"
          )
  
      def _pw_wires(w: Iterable) -> Wires:
          """Return the native Wires instance for a list of wire labels.
          w represents the wires of the PauliWord being processed. In case
          the PauliWord is empty ({}), choose any arbitrary wire from the
          PauliSentence it is composed in.
          """
          return w or Wires(self.wires[0]) if self.wires else self.wires
  
      if len(self) == 0:
          if not wire_order:
              raise ValueError(
                  "Can't get the matrix of an empty PauliSentence."
              )
          if format == "dense":
              return np.eye(2 ** len(wire_order))
          return sparse.eye(
              2 ** len(wire_order), format=format, dtype="complex128"
          )
  
      if format != "dense":
          return self._to_sparse_mat(
              wire_order, buffer_size=buffer_size
          )
  
      mats_and_wires_gen = (
          (
              coeff
              * pw.to_mat(
                  wire_order=_pw_wires(pw.wires), format=format
              ),
              _pw_wires(pw.wires),
          )
          for pw, coeff in self.items()
      )
  
      reduced_mat, result_wire_order = math.reduce_matrices(
          mats_and_wires_gen=mats_and_wires_gen, reduce_func=math.add
      )
  
      return math.expand_matrix(
          reduced_mat, result_wire_order, wire_order=wire_order
      )
  
imports: import warnings
  from copy import copy
  from functools import reduce, lru_cache
  from typing import Iterable
  import numpy
  from scipy import sparse
  import pennylane
  from pennylane import math
  from pennylane.typing import TensorLike
  from pennylane.wires import Wires
  from pennylane.operation import Tensor
  from pennylane.ops import Hamiltonian, Identity, PauliX, PauliY, PauliZ, prod, s_prod
label_desc: Use image node_id 14 for calling the PauliSentence obj's underlying member method code with example usage: obj.to_mat(wire_order, format, buffer_size) and returns: math, unknown, sparse, self, np