class_docstr: StatePrep(state, wires)
  Prepare subsystems using the given ket vector in the computational basis.
  
  **Details:**
  
  * Number of wires: Any (the operation can act on any number of wires)
  * Number of parameters: 1
  * Gradient recipe: None
  
  .. note::
  
      If the ``StatePrep`` operation is not supported natively on the
      target device, PennyLane will attempt to decompose the operation
      using the method developed by Möttönen et al. (Quantum Info. Comput.,
      2005).
  
  .. note::
  
      When called in the middle of a circuit, the action of the operation is defined
      as :math:`U|0\rangle = |\psi\rangle`
  
  Args:
      state (array[complex]): a state vector of size 2**len(wires)
      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.StatePrep(np.array([1, 0, 0, 0]), wires=range(2))
  ...     return qml.state()
  >>> print(example_circuit())
  [1.+0.j 0.+0.j 0.+0.j 0.+0.j]
class_docstr_tok: ["StatePrep","(","state",",","wires",")","Prepare","subsystems","using","the","given","ket","vector","in","the","computational","basis",".","*","*","Details",":","*","*","*","Number","of","wires",":","Any","(","the","operation","can","act","on","any","number","of","wires",")","*","Number","of","parameters",":","1","*","Gradient","recipe",":","None","..","note",":",":","If","the","``","StatePrep","``","operation","is","not","supported","natively","on","the","target","device",",","PennyLane","will","attempt","to","decompose","the","operation","using","the","method","developed","by","M\u00f6tt\u00f6nen","et","al",".","(","Quantum","Info",".","Comput.",",","2005",")",".","..","note",":",":","When","called","in","the","middle","of","a","circuit",",","the","action","of","the","operation","is","defined","as",":","math",":","`","U|0\\rangle","=","|\\psi\\rangle","`","Args",":","state","(","array","[","complex","]",")",":","a","state","vector","of","size","2","*","*","len","(","wires",")","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.StatePrep","(","np.array","(","[","1",",","0",",","0",",","0","]",")",",","wires=range","(","2",")",")","...","return","qml.state","(",")",">",">",">","print","(","example_circuit","(",")",")","[","1.+0.j","0.+0.j","0.+0.j","0.+0.j","]"]
code: def state_vector(self, wire_order=None):
      num_op_wires = len(self.wires)
      op_vector_shape = (
          (-1,) + (2,) * num_op_wires
          if self.batch_size
          else (2,) * num_op_wires
      )
      op_vector = math.reshape(self.parameters[0], op_vector_shape)
  
      if wire_order is None or Wires(wire_order) == self.wires:
          return op_vector
  
      wire_order = Wires(wire_order)
      if not wire_order.contains_wires(self.wires):
          raise WireError(
              f"Custom wire_order must contain all {self.name} wires"
          )
  
      # add zeros for each wire that isn't being set
      extra_wires = Wires(set(wire_order) - set(self.wires))
      for _ in extra_wires:
          op_vector = math.stack(
              [op_vector, math.zeros_like(op_vector)], axis=-1
          )
  
      # transpose from operator wire order to provided wire order
      current_wires = self.wires + extra_wires
      transpose_axes = [current_wires.index(w) for w in wire_order]
      if self.batch_size:
          transpose_axes = [0] + [a + 1 for a in transpose_axes]
      return math.transpose(op_vector, transpose_axes)
  
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 3 for calling the StatePrep obj's underlying member method code with example usage: obj.state_vector(wire_order) and returns: math, op_vector