class_docstr: Prepares a basis state on the given wires using a sequence of TShift 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.qutrit", wires=4)
  
      @qml.qnode(dev)
      def circuit(basis_state, obs):
          qml.QutritBasisStatePreparation(basis_state, wires=range(4))
          return [qml.expval(qml.THermitian(obs, wires=i)) for i in range(4)]
  
      basis_state = [0, 1, 1, 0]
      obs = np.array([[1, 1, 0], [1, -1, 0], [0, 0, np.sqrt(2)]]) / np.sqrt(2)
  
  >>> print(circuit(basis_state, obs))
  [array(0.70710678), array(-0.70710678), array(-0.70710678), array(0.70710678)]
class_docstr_tok: ["Prepares","a","basis","state","on","the","given","wires","using","a","sequence","of","TShift","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.qutrit","''",",","wires=4",")","@","qml.qnode","(","dev",")","def","circuit","(","basis_state",",","obs",")",":","qml.QutritBasisStatePreparation","(","basis_state",",","wires=range","(","4",")",")","return","[","qml.expval","(","qml.THermitian","(","obs",",","wires=i",")",")","for","i","in","range","(","4",")","]","basis_state","=","[","0",",","1",",","1",",","0","]","obs","=","np.array","(","[","[","1",",","1",",","0","]",",","[","1",",","-1",",","0","]",",","[","0",",","0",",","np.sqrt","(","2",")","]","]",")","\/","np.sqrt","(","2",")",">",">",">","print","(","circuit","(","basis_state",",","obs",")",")","[","array","(","0.70710678",")",",","array","(","-0.70710678",")",",","array","(","-0.70710678",")",",","array","(","0.70710678",")","]"]
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 any(bit not in [0, 1, 2] for bit in state):
              raise ValueError(
                  f"Basis states must only consist of 0s, 1s, and 2s; 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 pennylane
  from pennylane.operation import Operation, AnyWires
label_desc: Use image node_id 1 to create a new QutritBasisStatePreparation object from inherited base classes: Operation with example: obj = QutritBasisStatePreparation(basis_state, wires, id)