## `eigenkit.torch.layers.basic`

The basic quantum layer: one `Encoding`, one `Variational` block and a measurement.

It maps `n_qubits` input features to `n_qubits` expectation values, one for each qubit, in the chosen Pauli basis. For data reuploading or ensembles, see `Reupload` and `Ensemble`.

### `Basic`

Bases: `Module`

One `Encoding`, one `Variational` block and a measurement on each qubit.

Parameters:

| Name               | Type                         | Description                                                                                                                                                                                                                      | Default    |
| ------------------ | ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- |
| `n_qubits`         | `int`                        | The number of qubits, which is also the number of input features.                                                                                                                                                                | *required* |
| `depth`            | `int`                        | The number of variational layers.                                                                                                                                                                                                | *required* |
| `enc_rotation`     | `Literal['RX', 'RY', 'RZ']`  | The encoding rotation: "RX", "RY" or "RZ". Default: "RX".                                                                                                                                                                        | `'RX'`     |
| `var_rotation`     | `Literal['RX', 'RY', 'RZ']`  | The variational rotation. It is used only when variational_type="basic". The default, "RY", is off both the "RX" encoding axis and the "Z" measurement axis, and this is what lets the weights change the output. Default: "RY". | `'RY'`     |
| `variational_type` | `Literal['basic', 'strong']` | "basic", for one rotation and a controlled-NOT (CNOT) ladder in each layer, or "strong", for RZ, RY and RZ rotations and a CNOT ladder in each layer. Default: "basic".                                                          | `'basic'`  |
| `basis`            | `Literal['X', 'Y', 'Z']`     | The Pauli measurement basis: "X", "Y" or "Z". Default: "Z".                                                                                                                                                                      | `'Z'`      |
| `provider`         | `ProviderSpec`               | The backend that runs the circuit. Default: "numpy".                                                                                                                                                                             | `'numpy'`  |

Example

```python
import torch
from eigenkit import Basic

layer = Basic(n_qubits=4, depth=2)
out = layer(torch.randn(8, 4))  # shape (8, 4)
```

#### `provider`

The backend that the circuit of this layer was compiled for.

The constructor takes `provider=` in the same forms as `Circuit` (a registered name, a configuration or a backend object) and turns it into one `Provider`. This property returns it. The registered name is `provider.name`.

Returns:

| Name       | Type       | Description                           |
| ---------- | ---------- | ------------------------------------- |
| `provider` | `Provider` | The backend that the circuit runs on. |

#### `forward(x)`

Run the layer.

Parameters:

| Name | Type     | Description                                     | Default    |
| ---- | -------- | ----------------------------------------------- | ---------- |
| `x`  | `Tensor` | The input batch, of shape (batch, in_features). | *required* |

Returns:

| Name  | Type     | Description                             |
| ----- | -------- | --------------------------------------- |
| `out` | `Tensor` | The output of the layer for that batch. |
