prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  int to qml.BasisEmbedding
  ### Feature details
  
  Currently, to use `BasisEmbedding` we have to pass a list with the bits [0,1,0,0] for example to put a PauliX gate in the second qubit. It would be nice to be able to pass an integer number like:
  
  ```python
  qml.BasisEmbedding(4, wires = range(4))
  ```
  This result would be the same that:
  
  ```python
  qml.BasisEmbedding([0,1,0,0], wires = range(4))
  ```
  because 0100 is the number 4 in binary (note that PennyLane uses the convention $|q_0,q_1,\dots,q_{N-1}\rangle$ where $q_0$ is the most significant bit).
  
  This feature have a lot of applications, for example for qRAMs where we could do things like this one:
  
  ```python
  for i in range(16):
        qml.BasisEmbedding(i, wires = range(4))
       ### some stuff here
  ```
  
  ### Implementation
  
  I'm using this functions to translate the integer to the list:
  
  ```python
  def list_d(num, n_wires):
  
      mods = []
      while num != 0 or len(mods) != n_wires:
          mods.insert(0, num % 2)
          num //= 2
  
      return mods
  ```
  
  ```
  list_d(4,5)
  >>> [0,0,1,0,0]
  ```
  
  Probably incorporating this routine will be enough. However, some checks should be added because if num > 2^n_wires, the code will fail.
  
  
  ### How important would you say this feature is?
  
  1: Not important. Would be nice to have.
  
  ### Additional information
  
  Make sure that the order of the list is the same as Pennylane. 
  There are places where it is written from top to bottom and vice versa.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `pennylane/templates/embeddings/basis.py`
  Content:
  ```
  1 # Copyright 2018-2021 Xanadu Quantum Technologies Inc.
  2 
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 
  7 #     http://www.apache.org/licenses/LICENSE-2.0
  8 
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 r"""
  15 Contains the BasisEmbedding template.
  16 """
  17 # pylint: disable-msg=too-many-branches,too-many-arguments,protected-access
  18 import pennylane as qml
  19 from pennylane.operation import Operation, AnyWires
  20 from pennylane.wires import Wires
  21 
  22 
  23 class BasisEmbedding(Operation):
  24     r"""Encodes :math:`n` binary features into a basis state of :math:`n` qubits.
  25 
  26     For example, for ``features=np.array([0, 1, 0])``, the quantum system will be
  27     prepared in state :math:`|010 \rangle`.
  28 
  29     .. warning::
  30 
  31         ``BasisEmbedding`` calls a circuit whose architecture depends on the binary features.
  32         The ``features`` argument is therefore not differentiable when using the template, and
  33         gradients with respect to the argument cannot be computed by PennyLane.
  34 
  35     Args:
  36         features (tensor_like): binary input of shape ``(len(wires), )``
  37         wires (Any or Iterable[Any]): wires that the template acts on
  38 
  39     Example:
  40 
  41         Basis embedding encodes the binary feature vector into a basis state.
  42 
  43         .. code-block:: python
  44 
  45             dev = qml.device('default.qubit', wires=3)
  46 
  47             @qml.qnode(dev)
  48             def circuit(feature_vector):
  49                 qml.BasisEmbedding(features=feature_vector, wires=range(3))
  50                 return qml.state()
  51 
  52             X = [1,1,1]
  53 
  54         The resulting circuit is:
  55 
  56         >>> print(qml.draw(circuit, expansion_strategy="device")(X))
  57         0: ──X─┤  State
  58         1: ──X─┤  State
  59         2: ──X─┤  State
  60 
  61         And, the output state is:
  62 
  63         >>> print(circuit(X))
  64             [0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 1.+0.j]
  65 
  66         Thus, ``[1,1,1]`` is mapped to :math:`|111 \rangle`.
  67 
  68     """
  69 
  70     num_wires = AnyWires
  71     grad_method = None
  72 
  73     def __init__(self, features, wires, do_queue=True, id=None):
  74 
  75         wires = Wires(wires)
  76         shape = qml.math.shape(features)
  77 
  78         if len(shape) != 1:
  79             raise ValueError(f"Features must be one-dimensional; got shape {shape}.")
  80 
  81         n_features = shape[0]
  82         if n_features != len(wires):
  83             raise ValueError(f"Features must be of length {len(wires)}; got length {n_features}.")
  84 
  85         features = list(qml.math.toarray(features))
  86 
  87         if not set(features).issubset({0, 1}):
  88             raise ValueError(f"Basis state must only consist of 0s and 1s; got {features}")
  89 
  90         self._hyperparameters = {"basis_state": features}
  91 
  92         super().__init__(wires=wires, do_queue=do_queue, id=id)
  93 
  94     @property
  95     def num_params(self):
  96         return 0
  97 
  98     @staticmethod
  99     def compute_decomposition(wires, basis_state):  # pylint: disable=arguments-differ
  100         r"""Representation of the operator as a product of other operators.
  101 
  102         .. math:: O = O_1 O_2 \dots O_n.
  103 
  104 
  105 
  106         .. seealso:: :meth:`~.BasisEmbedding.decomposition`.
  107 
  108         Args:
  109             features (tensor-like): binary input of shape ``(len(wires), )``
  110             wires (Any or Iterable[Any]): wires that the operator acts on
  111 
  112         Returns:
  113             list[.Operator]: decomposition of the operator
  114 
  115         **Example**
  116 
  117         >>> features = torch.tensor([1, 0, 1])
  118         >>> qml.BasisEmbedding.compute_decomposition(features, wires=["a", "b", "c"])
  119         [PauliX(wires=['a']),
  120          PauliX(wires=['c'])]
  121         """
  122         ops_list = []
  123         for wire, bit in zip(wires, basis_state):
  124             if bit == 1:
  125                 ops_list.append(qml.PauliX(wire))
  126 
  127         return ops_list
  128
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/pennylane/templates/embeddings/basis.py b/pennylane/templates/embeddings/basis.py
  --- a/pennylane/templates/embeddings/basis.py
  +++ b/pennylane/templates/embeddings/basis.py
  @@ -23,8 +23,8 @@
   class BasisEmbedding(Operation):
       r"""Encodes :math:`n` binary features into a basis state of :math:`n` qubits.
   
  -    For example, for ``features=np.array([0, 1, 0])``, the quantum system will be
  -    prepared in state :math:`|010 \rangle`.
  +    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::
   
  @@ -72,6 +72,10 @@
   
       def __init__(self, features, wires, do_queue=True, id=None):
   
  +        if isinstance(features, int):
  +            bin_string = f"{features:b}".zfill(len(wires))
  +            features = [1 if d == "1" else 0 for d in bin_string]
  +
           wires = Wires(wires)
           shape = qml.math.shape(features)
   
  @@ -80,7 +84,9 @@
   
           n_features = shape[0]
           if n_features != len(wires):
  -            raise ValueError(f"Features must be of length {len(wires)}; got length {n_features}.")
  +            raise ValueError(
  +                f"Features must be of length {len(wires)}; got length {n_features} (features={features})."
  +            )
   
           features = list(qml.math.toarray(features))
  
verification_info: {"golden_diff": "diff --git a/pennylane/templates/embeddings/basis.py b/pennylane/templates/embeddings/basis.py\n--- a/pennylane/templates/embeddings/basis.py\n+++ b/pennylane/templates/embeddings/basis.py\n@@ -23,8 +23,8 @@\n class BasisEmbedding(Operation):\n     r\"\"\"Encodes :math:`n` binary features into a basis state of :math:`n` qubits.\n \n-    For example, for ``features=np.array([0, 1, 0])``, the quantum system will be\n-    prepared in state :math:`|010 \\rangle`.\n+    For example, for ``features=np.array([0, 1, 0])`` or ``features=2`` (binary 10), the\n+    quantum system will be prepared in state :math:`|010 \\rangle`.\n \n     .. warning::\n \n@@ -72,6 +72,10 @@\n \n     def __init__(self, features, wires, do_queue=True, id=None):\n \n+        if isinstance(features, int):\n+            bin_string = f\"{features:b}\".zfill(len(wires))\n+            features = [1 if d == \"1\" else 0 for d in bin_string]\n+\n         wires = Wires(wires)\n         shape = qml.math.shape(features)\n \n@@ -80,7 +84,9 @@\n \n         n_features = shape[0]\n         if n_features != len(wires):\n-            raise ValueError(f\"Features must be of length {len(wires)}; got length {n_features}.\")\n+            raise ValueError(\n+                f\"Features must be of length {len(wires)}; got length {n_features} (features={features}).\"\n+            )\n \n         features = list(qml.math.toarray(features))\n", "issue": "int to qml.BasisEmbedding\n### Feature details\r\n\r\nCurrently, to use `BasisEmbedding` we have to pass a list with the bits [0,1,0,0] for example to put a PauliX gate in the second qubit. It would be nice to be able to pass an integer number like:\r\n\r\n```python\r\nqml.BasisEmbedding(4, wires = range(4))\r\n```\r\nThis result would be the same that:\r\n\r\n```python\r\nqml.BasisEmbedding([0,1,0,0], wires = range(4))\r\n```\r\nbecause 0100 is the number 4 in binary (note that PennyLane uses the convention $|q_0,q_1,\\dots,q_{N-1}\\rangle$ where $q_0$ is the most significant bit).\r\n\r\nThis feature have a lot of applications, for example for qRAMs where we could do things like this one:\r\n\r\n```python\r\nfor i in range(16):\r\n      qml.BasisEmbedding(i, wires = range(4))\r\n     ### some stuff here\r\n```\r\n\r\n### Implementation\r\n\r\nI'm using this functions to translate the integer to the list:\r\n\r\n```python\r\ndef list_d(num, n_wires):\r\n\r\n    mods = []\r\n    while num != 0 or len(mods) != n_wires:\r\n        mods.insert(0, num % 2)\r\n        num //= 2\r\n\r\n    return mods\r\n```\r\n\r\n```\r\nlist_d(4,5)\r\n>>> [0,0,1,0,0]\r\n```\r\n\r\nProbably incorporating this routine will be enough. However, some checks should be added because if num > 2^n_wires, the code will fail.\r\n\r\n\r\n### How important would you say this feature is?\r\n\r\n1: Not important. Would be nice to have.\r\n\r\n### Additional information\r\n\r\nMake sure that the order of the list is the same as Pennylane. \r\nThere are places where it is written from top to bottom and vice versa.\n", "before_files": [{"content": "# Copyright 2018-2021 Xanadu Quantum Technologies Inc.\n\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n\n#     http://www.apache.org/licenses/LICENSE-2.0\n\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nr\"\"\"\nContains the BasisEmbedding template.\n\"\"\"\n# pylint: disable-msg=too-many-branches,too-many-arguments,protected-access\nimport pennylane as qml\nfrom pennylane.operation import Operation, AnyWires\nfrom pennylane.wires import Wires\n\n\nclass BasisEmbedding(Operation):\n    r\"\"\"Encodes :math:`n` binary features into a basis state of :math:`n` qubits.\n\n    For example, for ``features=np.array([0, 1, 0])``, the quantum system will be\n    prepared in state :math:`|010 \\rangle`.\n\n    .. warning::\n\n        ``BasisEmbedding`` calls a circuit whose architecture depends on the binary features.\n        The ``features`` argument is therefore not differentiable when using the template, and\n        gradients with respect to the argument cannot be computed by PennyLane.\n\n    Args:\n        features (tensor_like): binary input of shape ``(len(wires), )``\n        wires (Any or Iterable[Any]): wires that the template acts on\n\n    Example:\n\n        Basis embedding encodes the binary feature vector into a basis state.\n\n        .. code-block:: python\n\n            dev = qml.device('default.qubit', wires=3)\n\n            @qml.qnode(dev)\n            def circuit(feature_vector):\n                qml.BasisEmbedding(features=feature_vector, wires=range(3))\n                return qml.state()\n\n            X = [1,1,1]\n\n        The resulting circuit is:\n\n        >>> print(qml.draw(circuit, expansion_strategy=\"device\")(X))\n        0: \u2500\u2500X\u2500\u2524  State\n        1: \u2500\u2500X\u2500\u2524  State\n        2: \u2500\u2500X\u2500\u2524  State\n\n        And, the output state is:\n\n        >>> print(circuit(X))\n            [0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 1.+0.j]\n\n        Thus, ``[1,1,1]`` is mapped to :math:`|111 \\rangle`.\n\n    \"\"\"\n\n    num_wires = AnyWires\n    grad_method = None\n\n    def __init__(self, features, wires, do_queue=True, id=None):\n\n        wires = Wires(wires)\n        shape = qml.math.shape(features)\n\n        if len(shape) != 1:\n            raise ValueError(f\"Features must be one-dimensional; got shape {shape}.\")\n\n        n_features = shape[0]\n        if n_features != len(wires):\n            raise ValueError(f\"Features must be of length {len(wires)}; got length {n_features}.\")\n\n        features = list(qml.math.toarray(features))\n\n        if not set(features).issubset({0, 1}):\n            raise ValueError(f\"Basis state must only consist of 0s and 1s; got {features}\")\n\n        self._hyperparameters = {\"basis_state\": features}\n\n        super().__init__(wires=wires, do_queue=do_queue, id=id)\n\n    @property\n    def num_params(self):\n        return 0\n\n    @staticmethod\n    def compute_decomposition(wires, basis_state):  # pylint: disable=arguments-differ\n        r\"\"\"Representation of the operator as a product of other operators.\n\n        .. math:: O = O_1 O_2 \\dots O_n.\n\n\n\n        .. seealso:: :meth:`~.BasisEmbedding.decomposition`.\n\n        Args:\n            features (tensor-like): binary input of shape ``(len(wires), )``\n            wires (Any or Iterable[Any]): wires that the operator acts on\n\n        Returns:\n            list[.Operator]: decomposition of the operator\n\n        **Example**\n\n        >>> features = torch.tensor([1, 0, 1])\n        >>> qml.BasisEmbedding.compute_decomposition(features, wires=[\"a\", \"b\", \"c\"])\n        [PauliX(wires=['a']),\n         PauliX(wires=['c'])]\n        \"\"\"\n        ops_list = []\n        for wire, bit in zip(wires, basis_state):\n            if bit == 1:\n                ops_list.append(qml.PauliX(wire))\n\n        return ops_list\n", "path": "pennylane/templates/embeddings/basis.py"}], "after_files": [{"content": "# Copyright 2018-2021 Xanadu Quantum Technologies Inc.\n\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n\n#     http://www.apache.org/licenses/LICENSE-2.0\n\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nr\"\"\"\nContains the BasisEmbedding template.\n\"\"\"\n# pylint: disable-msg=too-many-branches,too-many-arguments,protected-access\nimport pennylane as qml\nfrom pennylane.operation import Operation, AnyWires\nfrom pennylane.wires import Wires\n\n\nclass BasisEmbedding(Operation):\n    r\"\"\"Encodes :math:`n` binary features into a basis state of :math:`n` qubits.\n\n    For example, for ``features=np.array([0, 1, 0])`` or ``features=2`` (binary 10), the\n    quantum system will be prepared in state :math:`|010 \\rangle`.\n\n    .. warning::\n\n        ``BasisEmbedding`` calls a circuit whose architecture depends on the binary features.\n        The ``features`` argument is therefore not differentiable when using the template, and\n        gradients with respect to the argument cannot be computed by PennyLane.\n\n    Args:\n        features (tensor_like): binary input of shape ``(len(wires), )``\n        wires (Any or Iterable[Any]): wires that the template acts on\n\n    Example:\n\n        Basis embedding encodes the binary feature vector into a basis state.\n\n        .. code-block:: python\n\n            dev = qml.device('default.qubit', wires=3)\n\n            @qml.qnode(dev)\n            def circuit(feature_vector):\n                qml.BasisEmbedding(features=feature_vector, wires=range(3))\n                return qml.state()\n\n            X = [1,1,1]\n\n        The resulting circuit is:\n\n        >>> print(qml.draw(circuit, expansion_strategy=\"device\")(X))\n        0: \u2500\u2500X\u2500\u2524  State\n        1: \u2500\u2500X\u2500\u2524  State\n        2: \u2500\u2500X\u2500\u2524  State\n\n        And, the output state is:\n\n        >>> print(circuit(X))\n            [0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 1.+0.j]\n\n        Thus, ``[1,1,1]`` is mapped to :math:`|111 \\rangle`.\n\n    \"\"\"\n\n    num_wires = AnyWires\n    grad_method = None\n\n    def __init__(self, features, wires, do_queue=True, id=None):\n\n        if isinstance(features, int):\n            bin_string = f\"{features:b}\".zfill(len(wires))\n            features = [1 if d == \"1\" else 0 for d in bin_string]\n\n        wires = Wires(wires)\n        shape = qml.math.shape(features)\n\n        if len(shape) != 1:\n            raise ValueError(f\"Features must be one-dimensional; got shape {shape}.\")\n\n        n_features = shape[0]\n        if n_features != len(wires):\n            raise ValueError(\n                f\"Features must be of length {len(wires)}; got length {n_features} (features={features}).\"\n            )\n\n        features = list(qml.math.toarray(features))\n\n        if not set(features).issubset({0, 1}):\n            raise ValueError(f\"Basis state must only consist of 0s and 1s; got {features}\")\n\n        self._hyperparameters = {\"basis_state\": features}\n\n        super().__init__(wires=wires, do_queue=do_queue, id=id)\n\n    @property\n    def num_params(self):\n        return 0\n\n    @staticmethod\n    def compute_decomposition(wires, basis_state):  # pylint: disable=arguments-differ\n        r\"\"\"Representation of the operator as a product of other operators.\n\n        .. math:: O = O_1 O_2 \\dots O_n.\n\n\n\n        .. seealso:: :meth:`~.BasisEmbedding.decomposition`.\n\n        Args:\n            features (tensor-like): binary input of shape ``(len(wires), )``\n            wires (Any or Iterable[Any]): wires that the operator acts on\n\n        Returns:\n            list[.Operator]: decomposition of the operator\n\n        **Example**\n\n        >>> features = torch.tensor([1, 0, 1])\n        >>> qml.BasisEmbedding.compute_decomposition(features, wires=[\"a\", \"b\", \"c\"])\n        [PauliX(wires=['a']),\n         PauliX(wires=['c'])]\n        \"\"\"\n        ops_list = []\n        for wire, bit in zip(wires, basis_state):\n            if bit == 1:\n                ops_list.append(qml.PauliX(wire))\n\n        return ops_list\n", "path": "pennylane/templates/embeddings/basis.py"}]}