class_docstr: Observable corresponding to the state projector :math:`P=\ket{\phi}\bra{\phi}`, where
  :math:`\phi` denotes a state.
class_docstr_tok: ["Observable","corresponding","to","the","state","projector",":","math",":","`","P=\\ket","{","\\phi","}","\\bra","{","\\phi","}","`",",","where",":","math",":","`","\\phi","`","denotes","a","state","."]
docstr: A customizable string representation of the operator.
  
  Args:
      decimals=None (int): If ``None``, no parameters are included. Else,
          specifies how to round the parameters.
      base_label=None (str): overwrite the non-parameter component of the label.
      cache=None (dict): dictionary that caries information between label calls
          in the same drawing.
  
  Returns:
      str: label to use in drawings.
  
  **Example:**
  
  >>> state_vector = np.array([0, 1, 1, 0])/np.sqrt(2)
  >>> qml.Projector(state_vector, wires=(0, 1)).label()
  'P'
  >>> qml.Projector(state_vector, wires=(0, 1)).label(base_label="hi!")
  'hi!'
  >>> dev = qml.device("default.qubit", wires=1)
  >>> @qml.qnode(dev)
  >>> def circuit(state):
  ...     return qml.expval(qml.Projector(state, [0]))
  >>> print(qml.draw(circuit)([1, 0]))
  0: ───┤  <|0⟩⟨0|>
  >>> print(qml.draw(circuit)(np.array([1, 1]) / np.sqrt(2)))
  0: ───┤  <P(M0)>
  M0 =
  [0.70710678 0.70710678]
docstr_tok: ["A","customizable","string","representation","of","the","operator",".","Args",":","decimals=None","(","int",")",":","If","``","None","``",",","no","parameters","are","included",".","Else",",","specifies","how","to","round","the","parameters",".","base_label=None","(","str",")",":","overwrite","the","non-parameter","component","of","the","label",".","cache=None","(","dict",")",":","dictionary","that","caries","information","between","label","calls","in","the","same","drawing",".","Returns",":","str",":","label","to","use","in","drawings",".","*","*","Example",":","*","*",">",">",">","state_vector","=","np.array","(","[","0",",","1",",","1",",","0","]",")","\/np.sqrt","(","2",")",">",">",">","qml.Projector","(","state_vector",",","wires=","(","0",",","1",")",")",".label","(",")","'","P'",">",">",">","qml.Projector","(","state_vector",",","wires=","(","0",",","1",")",")",".label","(","base_label=","''","hi","!","''",")","'hi","!","'",">",">",">","dev","=","qml.device","(","``","default.qubit","''",",","wires=1",")",">",">",">","@","qml.qnode","(","dev",")",">",">",">","def","circuit","(","state",")",":","...","return","qml.expval","(","qml.Projector","(","state",",","[","0","]",")",")",">",">",">","print","(","qml.draw","(","circuit",")","(","[","1",",","0","]",")",")","0",":","\u2500\u2500\u2500\u2524","<","|0\u27e9\u27e80|",">",">",">",">","print","(","qml.draw","(","circuit",")","(","np.array","(","[","1",",","1","]",")","\/","np.sqrt","(","2",")",")",")","0",":","\u2500\u2500\u2500\u2524","<","P","(","M0",")",">","M0","=","[","0.70710678","0.70710678","]"]
code: def label(self, decimals=None, base_label=None, cache=None):
      r"""A customizable string representation of the operator.
  
      Args:
          decimals=None (int): If ``None``, no parameters are included. Else,
              specifies how to round the parameters.
          base_label=None (str): overwrite the non-parameter component of the label.
          cache=None (dict): dictionary that caries information between label calls
              in the same drawing.
  
      Returns:
          str: label to use in drawings.
  
      **Example:**
  
      >>> state_vector = np.array([0, 1, 1, 0])/np.sqrt(2)
      >>> qml.Projector(state_vector, wires=(0, 1)).label()
      'P'
      >>> qml.Projector(state_vector, wires=(0, 1)).label(base_label="hi!")
      'hi!'
      >>> dev = qml.device("default.qubit", wires=1)
      >>> @qml.qnode(dev)
      >>> def circuit(state):
      ...     return qml.expval(qml.Projector(state, [0]))
      >>> print(qml.draw(circuit)([1, 0]))
      0: ───┤  <|0⟩⟨0|>
      >>> print(qml.draw(circuit)(np.array([1, 1]) / np.sqrt(2)))
      0: ───┤  <P(M0)>
      M0 =
      [0.70710678 0.70710678]
  
      """
      if base_label is not None:
          return base_label
  
      state_vector = self.parameters[0]
      n_wires = int(qml.math.log2(len(state_vector)))
      basis_state_idx = qml.math.nonzero(state_vector)[0]
  
      if len(basis_state_idx) == 1:
          basis_string = f"{basis_state_idx[0]:0{n_wires}b}"
          return f"|{basis_string}⟩⟨{basis_string}|"
  
      if cache is None or not isinstance(
          cache.get("matrices", None), list
      ):
          return "P"
  
      mat_num = len(cache["matrices"])
      cache["matrices"].append(self.parameters[0])
      return f"P(M{mat_num})"
  
imports: from copy import copy
  from collections.abc import Sequence
  import numpy
  from scipy.sparse import csr_matrix
  import pennylane
  from pennylane.operation import AnyWires, Observable, Operation
  from pennylane.wires import Wires
  from .matrix_ops import QubitUnitary
label_desc: Use image node_id 3 for calling the StateVectorProjector obj's underlying member method code with example usage: obj.label(decimals, base_label, cache) and returns: str, mat_num, str, base_label, str, basis_string, str, basis_string, str, str