> For the complete documentation index, see [llms.txt](https://docs.tensorleap.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tensorleap.ai/tensorleap-integration/python-api/code_loader/decorators.md).

# Decorators

{% hint style="info" %}
Decorators replace the previous [leap\_binder bindings](https://docs.tensorleap.ai/tensorleap-integration/python-api/code_loader/leap_binder.md). New integrations should use decorators only.
{% endhint %}

The Tensorleap decorators register your integration functions with the platform. All of them are imported from `code_loader.inner_leap_binder.leapbinder_decorators`.

### Dataset

| Decorator                                                                                                                                                    | Registers                                                                     | Required              |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------- | --------------------- |
| [@tensorleap\_preprocess](https://docs.tensorleap.ai/tensorleap-integration/python-api/code_loader/decorators/tensorleap_preprocess.md)                      | The function that splits the dataset into training, validation and other sets | Yes                   |
| [@tensorleap\_input\_encoder](https://docs.tensorleap.ai/tensorleap-integration/python-api/code_loader/decorators/tensorleap_input_encoder.md)               | A function that returns one model input for a sample                          | Yes                   |
| [@tensorleap\_gt\_encoder](https://docs.tensorleap.ai/tensorleap-integration/python-api/code_loader/decorators/tensorleap_gt_encoder.md)                     | A function that returns one ground truth for a sample                         | Yes, for labeled data |
| [@tensorleap\_metadata](https://docs.tensorleap.ai/tensorleap-integration/python-api/code_loader/decorators/tensorleap_metadata.md)                          | A function that returns metadata values for a sample                          | No                    |
| [@tensorleap\_unlabeled\_preprocess](https://docs.tensorleap.ai/tensorleap-integration/python-api/code_loader/decorators/tensorleap_unlabeled_preprocess.md) | A separate preprocess for unlabeled data                                      | No                    |
| [@tensorleap\_custom\_latent\_space](https://docs.tensorleap.ai/tensorleap-integration/python-api/code_loader/decorators/tensorleap_custom_latent_space.md)  | A user-defined embedding of each sample                                       | No                    |
| [@tensorleap\_simulation](https://docs.tensorleap.ai/tensorleap-integration/python-api/code_loader/decorators/tensorleap_simulation.md)                      | A function that generates synthetic samples                                   | No                    |

### Model

| Decorator                                                                                                                                | Registers                                                       | Required |
| ---------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- | -------- |
| [@tensorleap\_load\_model](https://docs.tensorleap.ai/tensorleap-integration/python-api/code_loader/decorators/tensorleap_load_model.md) | The function that loads the model, and the names of its outputs | Yes      |

### Losses, metrics and visualizers

| Decorator                                                                                                                                              | Registers             | Required |
| ------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------- | -------- |
| [@tensorleap\_custom\_loss](https://docs.tensorleap.ai/tensorleap-integration/python-api/code_loader/decorators/tensorleap_custom_loss.md)             | A loss function       | Yes      |
| [@tensorleap\_custom\_metric](https://docs.tensorleap.ai/tensorleap-integration/python-api/code_loader/decorators/tensorleap_custom_metric.md)         | A metric function     | No       |
| [@tensorleap\_custom\_visualizer](https://docs.tensorleap.ai/tensorleap-integration/python-api/code_loader/decorators/tensorleap_custom_visualizer.md) | A visualizer function | No       |

### Integration test

| Decorator                                                                                                                                            | Registers                                                                                        | Required |
| ---------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ | -------- |
| [@tensorleap\_integration\_test](https://docs.tensorleap.ai/tensorleap-integration/python-api/code_loader/decorators/tensorleap_integration_test.md) | The function that calls all of the above for one sample, and tells the platform how they connect | Yes      |

{% hint style="info" %}
The platform learns how losses, metrics and visualizers connect to the encoders and the model from the calls in the integration test. A loss, metric or visualizer that the integration test never calls has no inputs connected on the platform.
{% endhint %}

### Names

Every `name` argument must be unique within its kind: two input encoders, two metrics or two visualizers with the same name raise an error when the script is loaded.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.tensorleap.ai/tensorleap-integration/python-api/code_loader/decorators.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
