## `eigenkit.torch.layers.ensemble`

An ensemble of independent quantum circuits, one for each chunk of the input.

It splits the input into chunks of `n_qubits` features and runs one independent circuit on each chunk, each with its own weights. The outputs are concatenated along the feature dimension.

### `Ensemble`

Bases: `Module`

An ensemble of independent quantum circuits, one for each chunk of the input.

Parameters:

| Name               | Type                         | Description                                                                             | Default    |
| ------------------ | ---------------------------- | --------------------------------------------------------------------------------------- | ---------- |
| `in_features`      | `int`                        | The total number of input features. It must be a multiple of n_qubits.                  | *required* |
| `n_qubits`         | `int`                        | The number of qubits of each circuit.                                                   | *required* |
| `depth`            | `int`                        | The number of variational layers of each circuit.                                       | *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". Default: "RY". | `'RY'`     |
| `variational_type` | `Literal['basic', 'strong']` | "basic" or "strong". Default: "strong".                                                 | `'strong'` |
| `basis`            | `Literal['X', 'Y', 'Z']`     | The Pauli measurement basis: "X", "Y" or "Z". Default: "Z".                             | `'Z'`      |
| `provider`         | `ProviderSpec`               | The backend that runs the circuits. Default: "numpy".                                   | `'numpy'`  |

Example

```python
import torch
from eigenkit import Ensemble

layer = Ensemble(in_features=20, n_qubits=4, depth=5)
out = layer(torch.randn(128, 20))  # shape (128, 20)
```

#### `provider`

The backend that the circuits of this layer were 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 circuits run 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. |
