> 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/tensorleap_integration_test.md).

# @tensorleap\_integration\_test

The tensorleap\_integration\_test decorates Tensorleap's [integration test](/tensorleap-integration/integration-test.md), and is used to instruct the platform on what code interfaces should be used when analyzing your model and to locally test the validity of a Tensorleap integration script.

```python
@tensorleap_integration_test()
def integration_test(idx: int, subset: PreprocessResponse) -> None:
    pass
```

### Examples

#### Basic Usage

```python
from code_loader.plot_functions.visualize import visualize
from code_loader.inner_leap_binder.leapbinder_decorators import tensorleap_integration_test

# Import your integration functions (defined in your integration script)
from leap_integration import (
    preprocess_func, input_encoder, gt_encoder,
    image_visualizer, my_metric, my_loss, load_model
)

@tensorleap_integration_test()
def integration_test(idx, subset):
    image = input_encoder(idx, subset)
    gt = gt_encoder(idx, subset)

    model = load_model()
    y_pred = model([image])

    img_vis = image_visualizer(image)
    visualize(img_vis)

    metric_res = my_metric(gt, y_pred)
    loss_res = my_loss(gt, y_pred)
    print(metric_res, loss_res)


if __name__ == '__main__':
    train, val, *_ = preprocess_func()
    for i in range(3):
        integration_test(i, train)
        integration_test(i, val)
```


---

# 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 dynamically by asking a question.

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

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
