class_docstr: Encodes :math:`n` binary features into a basis state of :math:`n` qubits.
  
  For example, for ``features=np.array([0, 1, 0])`` or ``features=2`` (binary 10), the
  quantum system will be prepared in state :math:`|010 \rangle`.
  
  .. warning::
  
      ``BasisEmbedding`` calls a circuit whose architecture depends on the binary features.
      The ``features`` argument is therefore not differentiable when using the template, and
      gradients with respect to the argument cannot be computed by PennyLane.
  
  Args:
      features (tensor_like): binary input of shape ``(len(wires), )``
      wires (Any or Iterable[Any]): wires that the template acts on
  
  Example:
  
      Basis embedding encodes the binary feature vector into a basis state.
  
      .. code-block:: python
  
          dev = qml.device('default.qubit', wires=3)
  
          @qml.qnode(dev)
          def circuit(feature_vector):
              qml.BasisEmbedding(features=feature_vector, wires=range(3))
              return qml.state()
  
          X = [1,1,1]
  
      The resulting circuit is:
  
      >>> print(qml.draw(circuit, expansion_strategy="device")(X))
      0: ──X─┤  State
      1: ──X─┤  State
      2: ──X─┤  State
  
      And, the output state is:
  
      >>> print(circuit(X))
          [0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 1.+0.j]
  
      Thus, ``[1,1,1]`` is mapped to :math:`|111 \rangle`.
code: def __init__(self, features, wires, id=None):
      if isinstance(features, list):
          features = qml.math.stack(features)
  
      tracing = qml.math.is_abstract(features)
  
      if qml.math.shape(features) == ():
          if not tracing and features >= 2 ** len(wires):
              raise ValueError(
                  f"Features must be of length {len(wires)}, got features={features} which is >= {2 ** len(wires)}"
              )
          bin = 2 ** np.arange(len(wires))[::-1]
          features = qml.math.where((features & bin) > 0, 1, 0)
  
      wires = Wires(wires)
      shape = qml.math.shape(features)
  
      if len(shape) != 1:
          raise ValueError(
              f"Features must be one-dimensional; got shape {shape}."
          )
  
      n_features = shape[0]
      if n_features != len(wires):
          raise ValueError(
              f"Features must be of length {len(wires)}; got length {n_features} (features={features})."
          )
  
      if not tracing:
          features = list(qml.math.toarray(features))
          if not set(features).issubset({0, 1}):
              raise ValueError(
                  f"Basis state must only consist of 0s and 1s; got {features}"
              )
  
      self._hyperparameters = {"basis_state": features}
  
      super().__init__(wires=wires, id=id)
  
file_path: pennylane/pennylane/templates/embeddings/basis.py
imports: import numpy
  import pennylane
  from pennylane.operation import Operation, AnyWires
  from pennylane.wires import Wires
label_desc: Use image node_id 3 to create a new BasisEmbedding object from inherited base classes: Operation with example: obj = BasisEmbedding(features, wires, id)