# @tensorleap\_preprocess

The `tensorleap_preprocess` decorates a [**Preprocessing Function**](/tensorleap-integration/writing-integration-code/preprocess-function.md)

```python
@tensorleap_preprocess()
def preprocess_func_leap() -> List[PreprocessResponse]:
    pass
```

### Examples

#### Basic Usage

```python
from code_loader.contract.datasetclasses import PreprocessResponse
from code_loader.contract.enums import DataStateType
from code_loader.inner_leap_binder.leapbinder_decorators import tensorleap_preprocess

# Preprocessing Function
@tensorleap_preprocess()
def preprocessing_func() -> List[PreprocessResponse]:
    ...
    train = PreprocessResponse(length=len(train_df), data=train_df, state=DataStateType.training)
    val = PreprocessResponse(length=len(val_df), data=val_df, state=DataStateType.validation)
    test = PreprocessResponse(length=len(test_df), data=test_df, state=DataStateType.test)
    unlabeled = PreprocessResponse(length=len(test_df), data=unlabeled_df, state=DataStateType.unlabeled)

    return [train, val, test, unlabeled]
```

Usage within the full script can be found at the [**Dataset Script**](/tensorleap-integration/writing-integration-code.md#dataset-script).

#### Guides

Full examples can be found at the **Dataset Integration** section of the following guides:

* [**MNIST Guide**](/guides/full-guides/mnist-guide.md)
* [**IMDB Guide**](/guides/full-guides/imdb-guide.md)


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
