# Visualizer Function

Tensorleap enables visualizations of data within the model graph by connecting a [**Visualizer**](/user-interface/project/network/network-mapping/create-a-mapping-deprecated/visualizer-node.md) block to a node's output tensor. This allows you to visualize the model's input, prediction, ground truth, or any internal tensor.

By default, the following naive Visualizers are provided (in the UI):

* Image
* Graph
* Numeric
* HorizontalBar
* Text
* ImageMask
* TextMask

These naive visualizers shows the data as-is, but in many cases, there is a need to write our own **Visualizer Function** to make sense of the data. For example:

* Converting *tokenized* data to text *words*
* Custom post-processing
* Draw landmarks on images
* Apply transforms

Example of a visualizer function:

```python
import numpy as np
from code_loader.contract.visualizer_classes import LeapText
from code_loader.contract.enums import LeapDataType
...

@tensorleap_custom_visualizer(name="input_visualizer", visualizer_type=LeapDataType.Text)
def input_visualizer(input_ids: np.ndarray) -> LeapText:
    input_ids = np.squeeze(input_ids)
    text = decode_token_ids(input_ids)
    return LeapText(text)
```

The [@tensorleap\_custom\_visualizer](/tensorleap-integration/python-api/code_loader/decorators/tensorleap_custom_visualizer.md)decorator registers each visualizer into the Tensorleap integration.

These functions should return one of the following types defined in [**visualizer\_classes**](/tensorleap-integration/python-api/code_loader/visualizer_classes.md).

The [**visualizer\_classes**](/tensorleap-integration/python-api/code_loader/visualizer_classes.md) pages contain additional, visualizer specific, examples. Moreover, full script usage can be found at [**Integration Script**](/tensorleap-integration/writing-integration-code.md#dataset-script).


---

# 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/writing-integration-code/visualizer-function.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.
