# core.Requirements

``` python
core.Requirements(
    vjp=False,
    vjp_twice=False,
    jvp=False,
    vmap=False,
    hooks=(),
    needs_targets=False,
    needs_sample=False,
    needs_distribution=False,
    needs_output_hessian=False,
    needs_closed_form_hessian=False,
    late_scale=True,
    additive_stat=True,
    weights=True,
    input_type=None,
    one_of=(),
)
```

What a method needs from the model beyond one backward pass, and from the likelihood.

`missing` and `Capabilities.check` cover the model; `check_likelihood` covers the likelihood needs.

## Parameters

| Name | Type | Description | Default |
|----|----|----|----|
| vjp | bool | Needs `torch.func.vjp`. | `False` |
| vjp_twice | bool | Needs a VJP of a VJP: $J t$ from reverse mode alone, which differentiates the model’s backward. | `False` |
| jvp | bool | Needs `torch.func.jvp` (forward-mode AD). | `False` |
| vmap | bool | Needs `torch.func.vmap`. | `False` |
| hooks | tuple\[type\[nn.Module\], …\] | Module types whose hooks must fire. Hook-based methods also need the subset’s params to be the module’s own (live) parameters, which the probe checks. | `()` |
| needs_targets | bool | Needs targets in every batch. | `False` |
| needs_sample | bool | The likelihood draws targets (`HasSample` or `HasDistribution`). | `False` |
| needs_distribution | bool | The likelihood has `HasDistribution`. | `False` |
| needs_closed_form_hessian | bool | Needs the closed-form output Hessian (`HasOutputHessian`), as a method with `fisher="exact"` does. | `False` |
| needs_output_hessian | bool | Needs an output Hessian: the closed form (`HasOutputHessian`) or the MC Fisher (sampling). | `False` |
| late_scale | bool | True: the statistic is linear in a `LateLikelihood`’s `curvature_scale`, so its hyperparameters can be applied after the fit. False (e.g. the empirical Fisher, which is quadratic in the score): `check_likelihood` refuses a `LateLikelihood` with a late hyperparameter, one whose `unit()` is another object. | `True` |
| additive_stat | bool | True: the statistic is a sum, so `mix` can scale it. False: it still merges under `+` (e.g. a top-M subset), so `all_reduce` works, but it can’t be mixed. | `True` |
| weights | bool | The method honours `Batch.weights`. | `True` |
| input_type | type \| None | Required type of `Batch.inputs`, e.g. `Tensor` for backends that can’t take mappings. `None` accepts any. | `None` |
| one_of | tuple\[Requirements, …\] | Alternatives; at least one must hold. | `()` |

## Methods

| Name | Description |
|----|----|
| [check_batch](#laplacekit.core.Requirements.check_batch) | Check `batch` against `needs_targets`, `input_type` and `weights`. |
| [missing](#laplacekit.core.Requirements.missing) | Capabilities this requirement lacks. |
| [satisfies](#laplacekit.core.Requirements.satisfies) | Whether `caps` has everything `missing` checks. |

### check_batch

``` python
core.Requirements.check_batch(batch, what, /)
```

Check `batch` against `needs_targets`, `input_type` and `weights`.

The fit calls this on each batch before the method sees it.

#### Parameters

| Name  | Type  | Description                                    | Default    |
|-------|-------|------------------------------------------------|------------|
| batch | Batch | The batch to check.                            | *required* |
| what  | str   | Name of the method, used in the error message. | *required* |

#### Raises

| Name | Type | Description |
|----|----|----|
|  | CapabilityError | The batch has no targets but `needs_targets` is set, its inputs are not of `input_type`, or it has weights but `weights` is False. |

### missing

``` python
core.Requirements.missing(caps)
```

Capabilities this requirement lacks.

Covers `vjp`, `vjp_twice`, `jvp`, `vmap` and `one_of`. Hooks are checked by `Capabilities.check`.

#### Parameters

| Name | Type         | Description           | Default    |
|------|--------------|-----------------------|------------|
| caps | Capabilities | What the probe found. | *required* |

#### Returns

| Name | Type | Description |
|----|----|----|
|  | list\[str\] | Names of the missing capabilities, empty when satisfied. An unmet `one_of` adds one entry listing what each alternative lacks. |

### satisfies

``` python
core.Requirements.satisfies(caps)
```

Whether `caps` has everything `missing` checks.

#### Parameters

| Name | Type         | Description           | Default    |
|------|--------------|-----------------------|------------|
| caps | Capabilities | What the probe found. | *required* |

#### Returns

| Name | Type | Description                         |
|------|------|-------------------------------------|
|      | bool | True when `missing(caps)` is empty. |
