# `Tinkex.API.Training`
[🔗](https://github.com/North-Shore-AI/tinkex/blob/v0.4.0/lib/tinkex/api/training.ex#L1)

Training API endpoints.

Uses :training pool (sequential, long-running operations).
Pool size: 5 connections.

# `forward`

```elixir
@spec forward(
  map(),
  keyword()
) ::
  {:ok, Tinkex.Types.ForwardBackwardOutput.t() | map()}
  | {:error, Tinkex.Error.t()}
```

Forward pass only (inference).

This helper awaits the future internally. Use
`forward_future/2` to get the raw future response.

# `forward_backward`

```elixir
@spec forward_backward(
  map(),
  keyword()
) ::
  {:ok, Tinkex.Types.ForwardBackwardOutput.t() | map()}
  | {:error, Tinkex.Error.t()}
```

Forward-backward pass for gradient computation.

This helper awaits the future internally. Use
`forward_backward_future/2` to get the raw future response.

## Examples

    Tinkex.API.Training.forward_backward(
      %{model_id: "...", inputs: [...]},
      config: config
    )

# `forward_backward_future`

```elixir
@spec forward_backward_future(
  map(),
  keyword()
) :: {:ok, map()} | {:error, Tinkex.Error.t()}
```

Forward-backward pass that returns a server-side future reference.

# `forward_future`

```elixir
@spec forward_future(
  map(),
  keyword()
) :: {:ok, map()} | {:error, Tinkex.Error.t()}
```

Forward pass that returns a server-side future reference.

Returns a future that can be polled for the forward pass result containing
logprobs that can be converted to Nx tensors via `TensorData.to_nx/1`.

# `optim_step`

```elixir
@spec optim_step(
  map(),
  keyword()
) ::
  {:ok, Tinkex.Types.OptimStepResponse.t() | map()} | {:error, Tinkex.Error.t()}
```

Optimizer step to update model parameters.

# `optim_step_future`

```elixir
@spec optim_step_future(
  map(),
  keyword()
) :: {:ok, map()} | {:error, Tinkex.Error.t()}
```

Optimizer step that returns a server-side future reference.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
