# helia_edge.trainers.steps

Training steps that dispatch on the active Keras backend.

## helia_edge.trainers.steps.NotSupported

`class` · `python`

```python
NotSupported()
```

The active Keras backend is not supported by this trainer.

Source: `helia_edge/trainers/steps.py:12`

## helia_edge.trainers.steps.require_backend

`function` · `python`

```python
require_backend(feature: str, supported: Sequence[str]) -> str
```

Return the active backend, or raise ``NotSupported`` naming ``feature`` and ``supported``.

Source: `helia_edge/trainers/steps.py:16`

## helia_edge.trainers.steps.no_grad

`function` · `python`

```python
no_grad() -> Iterator[None]
```

Disable gradient tracking on Torch; a no-op on other backends.

Source: `helia_edge/trainers/steps.py:24`

## helia_edge.trainers.steps.gradient_step

`function` · `python`

```python
gradient_step(
    model: keras.Model,
    loss_fn: Callable[[], tuple[Any, ...]],
    variables: Sequence[Any] | None = None,
) -> tuple[Any, ...]
```

Differentiate ``loss_fn`` with the active backend and apply ``model.optimizer`` once.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| model | keras.Model | Required | Compiled model whose optimizer applies the update. |
| loss_fn | Callable[[], tuple[Any, ...]] | Required | Computes ``(loss, *outputs)`` from the model's current weights. |
| variables | Sequence[Any] \| None | None | Variables to update; when None, the model's trainable weights after ``loss_fn`` runs, so variables created by a first (building) call are included. Variables without a gradient are skipped. |

**Returns**

| Name | Type | Description |
| --- | --- | --- |
| tuple | tuple[Any, ...] | What ``loss_fn`` returned. |

**Raises**

| Name | Description |
| --- | --- |
| NotSupported | On backends other than TensorFlow and Torch. |

Source: `helia_edge/trainers/steps.py:37`
