# reparameterizable

Python API: `luxonis_train.nodes.blocks.reparameterizable`

The interface for a block that folds its training-time branches into a single operation before export.

## Classes

### Reparameterizable

Base class for a module that changes its structure for export.

A subclass trains in one form, for example with parallel branches.
[reparameterize](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/nodes/blocks/reparameterizable.md)
changes it to a form with fewer operations and the same output in the eval state.
[restore](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/nodes/blocks/reparameterizable.md)
changes it back.
[BaseNode.set_export_mode](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/nodes/base_node.md)
calls
[reparameterize](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/nodes/blocks/reparameterizable.md)
on every such submodule of the node for `mode=True`, and
[restore](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/nodes/blocks/reparameterizable.md)
for `mode=False`. It does not check the current export mode.
[LuxonisLightningModule.reparameterize](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/lightning/luxonis_lightning.md)
calls
[reparameterize](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/nodes/blocks/reparameterizable.md)
without a change of the export mode.
[GeneralReparameterizableBlock](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/nodes/blocks/blocks.md)
is the subclass in this package.

#### Methods

##### reparameterize

```python
def reparameterize(self):
```

Change the module to its export form.

An implementation changes the module in place. In the eval state, `forward` must then give the same output with fewer operations.
[BaseNode.set_export_mode](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/nodes/base_node.md)
calls the method on each call with `mode=True`, also when export mode is already on. A call on a module in the export form must
thus change nothing.

##### restore

```python
def restore(self):
```

Change the module back to its training form.

An implementation undoes
[reparameterize](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/nodes/blocks/reparameterizable.md),
so that `forward` uses the training form again.
[BaseNode.set_export_mode](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/nodes/base_node.md)
calls the method on each call with `mode=False`, also when export mode is already off. A call on a module in the training form
must thus change nothing.
