def show_heatmap_on_text(text: str, text_encoding: torch.Tensor, rel_text: torch.Tensor):
    """
    Show the text relevance heatmap.
    Args:
        text (`str`):
            Text to show.
        text_encoding (`torch.Tensor`):
            Tokenized text.
        rel_text (`torch.Tensor`):
            Text relevance.

    """
    if not is_captum_available():
        models_log.warning('You should install Captum first. Please run `pip install captum`.')
        return None
    from captum.attr import visualization as viz  # pylint: disable=import-outside-toplevel
    if not is_matplotlib_available():
        models_log.warning('Matplotlib is not available.')
    from towhee.utils.matplotlib_utils import matplotlib
    import matplotlib.pylab as plt  # pylint: disable=import-outside-toplevel

    tokenizer = SimpleTokenizer()

    cls_idx = text_encoding.argmax(dim=-1)
    rel_text = rel_text[cls_idx, 1:cls_idx]
    text_scores = rel_text / rel_text.sum()
    text_scores = text_scores.flatten()
    text_tokens = tokenizer.encode(text)
    text_tokens_decoded = [tokenizer.decode([a]) for a in text_tokens]
    vis_data_records = [viz.VisualizationDataRecord(text_scores, 0, 0, 0, 0, 0, text_tokens_decoded, 1)]
    viz.visualize_text(vis_data_records)
    plt.show()
Show the text relevance heatmap.
Args:
text (`str`):
Text to show.
text_encoding (`torch.Tensor`):
Tokenized text.
rel_text (`torch.Tensor`):
Text relevance.
towhee/models/visualization/clip_visualization.py