# registry

Python API: `luxonis_train.registry`

Registries that map component names from a config to their classes.

Most components register through their base-class metaclass. The key is the class name unless `register_name` overrides it.
Predefined models also use versioned keys such as `DetectionModel:v1` and alias the latest version under the bare name and
`:latest`.

## Functions

### from_registry

```python
def from_registry(registry: Registry[type[T]], key: str, *args, **kwargs) -> T:
```

Create an instance of the class registered under a name.

The function gets the class for `key` from `registry` and calls it with `args` and `kwargs`. The registry raises `KeyError` when
it has no class under `key`.

> **Example**
> ```pycon
>>> import torch
>>> from luxonis_train.registry import OPTIMIZERS, from_registry
>>> params = [torch.nn.Parameter(torch.zeros(2))]
>>> optimizer = from_registry(OPTIMIZERS, "SGD", params, lr=0.1)
>>> type(optimizer).__name__, optimizer.defaults["lr"]
('SGD', 0.1)
```

Parameters

 * `registry` (`Registry[type[T]]`): The registry to search, for example [NODES](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/registry.md) or [OPTIMIZERS](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/registry.md).
 * `key` (`str`): The name of the registered class.
 * `*args`: The positional arguments for the constructor.
 * `**kwargs`: The keyword arguments for the constructor.

Returns

 * `T`: The result of the call. It is a new instance of the registered class, unless the class is a factory such as [ConfusionMatrix](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-train/luxonis-train-api-reference/attached_modules/metrics/confusion_matrix/confusion_matrix.md).

## Attributes

### CALLBACKS

### LOADERS

### LOSSES

### METRICS

### MODELS

### NODES

### OPTIMIZERS

### SCHEDULERS

### STRATEGIES

### T

### VISUALIZERS
