class_docstr: Prepares a basis state on the given wires using a sequence of Pauli-X gates.
  
  .. warning::
  
      ``basis_state`` influences the circuit architecture and is therefore incompatible with
      gradient computations.
  
  Args:
      basis_state (array): Input array of shape ``(n,)``, where n is the number of wires
          the state preparation acts on.
      wires (Iterable): wires that the template acts on
  
  **Example**
  
  .. code-block:: python
  
      dev = qml.device("default.qubit", wires=4)
  
      @qml.qnode(dev)
      def circuit(basis_state):
          qml.BasisStatePreparation(basis_state, wires=range(4))
          return [qml.expval(qml.PauliZ(wires=i)) for i in range(4)]
  
      basis_state = [0, 1, 1, 0]
  
  >>> print(circuit(basis_state))
  [ 1. -1. -1.  1.]
code: def __init__(self, basis_state, wires, id=None):
      basis_state = qml.math.stack(basis_state)
  
      # check if the `basis_state` param is batched
      batched = len(qml.math.shape(basis_state)) > 1
  
      state_batch = basis_state if batched else [basis_state]
  
      for i, state in enumerate(state_batch):
          shape = qml.math.shape(state)
  
          if len(shape) != 1:
              raise ValueError(
                  f"Basis states must be one-dimensional; state {i} has shape {shape}."
              )
  
          n_bits = shape[0]
          if n_bits != len(wires):
              raise ValueError(
                  f"Basis states must be of length {len(wires)}; state {i} has length {n_bits}."
              )
  
          if not qml.math.is_abstract(state):
              if any(bit not in [0, 1] for bit in state):
                  raise ValueError(
                      f"Basis states must only consist of 0s and 1s; state {i} is {state}"
                  )
  
      # TODO: basis_state should be a hyperparameter, not a trainable parameter.
      # However, this breaks a test that ensures compatibility with batch_transform.
      # The transform should be rewritten to support hyperparameters as well.
      super().__init__(basis_state, wires=wires, id=id)
  
imports: import numpy
  import pennylane
  from pennylane.operation import Operation, AnyWires
label_desc: Use image node_id 1 to create a new BasisStatePreparation object from inherited base classes: Operation with example: obj = BasisStatePreparation(basis_state, wires, id)