class_docstr: BasisState(n, wires)
  Prepares a single computational basis state.
  
  **Details:**
  
  * Number of wires: Any (the operation can act on any number of wires)
  * Number of parameters: 1
  * Gradient recipe: None (integer parameters not supported)
  
  .. note::
  
      If the ``BasisState`` operation is not supported natively on the
      target device, PennyLane will attempt to decompose the operation
      into :class:`~.PauliX` operations.
  
  .. note::
  
      When called in the middle of a circuit, the action of the operation is defined
      as :math:`U|0\rangle = |\psi\rangle`
  
  Args:
      n (array): prepares the basis state :math:`\ket{n}`, where ``n`` is an
          array of integers from the set :math:`\{0, 1\}`, i.e.,
          if ``n = np.array([0, 1, 0])``, prepares the state :math:`|010\rangle`.
      wires (Sequence[int] or int): the wire(s) the operation acts on
      id (str): custom label given to an operator instance,
          can be useful for some applications where the instance has to be identified.
  
  **Example**
  
  >>> dev = qml.device('default.qubit', wires=2)
  >>> @qml.qnode(dev)
  ... def example_circuit():
  ...     qml.BasisState(np.array([1, 1]), wires=range(2))
  ...     return qml.state()
  >>> print(example_circuit())
  [0.+0.j 0.+0.j 0.+0.j 1.+0.j]
class_docstr_tok: ["BasisState","(","n",",","wires",")","Prepares","a","single","computational","basis","state",".","*","*","Details",":","*","*","*","Number","of","wires",":","Any","(","the","operation","can","act","on","any","number","of","wires",")","*","Number","of","parameters",":","1","*","Gradient","recipe",":","None","(","integer","parameters","not","supported",")","..","note",":",":","If","the","``","BasisState","``","operation","is","not","supported","natively","on","the","target","device",",","PennyLane","will","attempt","to","decompose","the","operation","into",":","class",":","`","~.PauliX","`","operations",".","..","note",":",":","When","called","in","the","middle","of","a","circuit",",","the","action","of","the","operation","is","defined","as",":","math",":","`","U|0\\rangle","=","|\\psi\\rangle","`","Args",":","n","(","array",")",":","prepares","the","basis","state",":","math",":","`","\\ket","{","n","}","`",",","where","``","n","``","is","an","array","of","integers","from","the","set",":","math",":","`","\\","{","0",",","1\\","}","`",",","i.e.",",","if","``","n","=","np.array","(","[","0",",","1",",","0","]",")","``",",","prepares","the","state",":","math",":","`","|010\\rangle","`",".","wires","(","Sequence","[","int","]","or","int",")",":","the","wire","(","s",")","the","operation","acts","on","id","(","str",")",":","custom","label","given","to","an","operator","instance",",","can","be","useful","for","some","applications","where","the","instance","has","to","be","identified",".","*","*","Example","*","*",">",">",">","dev","=","qml.device","(","'default.qubit","'",",","wires=2",")",">",">",">","@","qml.qnode","(","dev",")","...","def","example_circuit","(",")",":","...","qml.BasisState","(","np.array","(","[","1",",","1","]",")",",","wires=range","(","2",")",")","...","return","qml.state","(",")",">",">",">","print","(","example_circuit","(",")",")","[","0.+0.j","0.+0.j","0.+0.j","1.+0.j","]"]
docstr: Returns a state-vector of shape ``(2,) * num_wires``.
docstr_tok: ["Returns","a","state-vector","of","shape","``","(","2",",",")","*","num_wires","``","."]
code: def state_vector(self, wire_order=None):
      """Returns a state-vector of shape ``(2,) * num_wires``."""
      prep_vals = self.parameters[0]
      if any(i not in [0, 1] for i in prep_vals):
          raise ValueError(
              "BasisState parameter must consist of 0 or 1 integers."
          )
  
      if (num_wires := len(self.wires)) != len(prep_vals):
          raise ValueError(
              "BasisState parameter and wires must be of equal length."
          )
  
      prep_vals = math.cast(prep_vals, int)
      if wire_order is None:
          indices = prep_vals
      else:
          if not Wires(wire_order).contains_wires(self.wires):
              raise WireError(
                  "Custom wire_order must contain all BasisState wires"
              )
          num_wires = len(wire_order)
          indices = [0] * num_wires
          for base_wire_label, value in zip(self.wires, prep_vals):
              indices[wire_order.index(base_wire_label)] = value
  
      ket = np.zeros((2,) * num_wires)
      ket[tuple(indices)] = 1
      return math.convert_like(ket, prep_vals)
  
file_path: pennylane/pennylane/ops/qubit/state_preparation.py
imports: import numpy
  from pennylane import math
  from pennylane.operation import AnyWires, Operation, StatePrepBase
  from pennylane.templates.state_preparations import BasisStatePreparation, MottonenStatePreparation
  from pennylane.wires import Wires, WireError
label_desc: Use image node_id 2 for calling the BasisState obj's underlying member method code with example usage: obj.state_vector(wire_order) and returns: math