code: def sentences_heatmap(sentences, probs, clf):
      fig, axes = plt.subplots(
          len(sentences),
          1,
          figsize=(20, len(sentences) * 0.95),
          dpi=160,
          squeeze=False,
      )
      axes = axes[:, 0]
  
      axes[0].axis("off")
  
      for i, ax in enumerate(axes):
          ax.add_patch(
              Rectangle(
                  (0.0, 0.05),
                  0.99,
                  0.90,
                  fill=None,
                  alpha=1,
                  color="r" if clf[i] == 0 else "g",
                  linewidth=2,
              )
          )
  
          word_pos = 0.00
          cmap = plt.cm.copper
          norm = matplotlib.colors.Normalize(vmin=0.0, vmax=1.0)
  
          for j, (word, prob) in enumerate(zip(sentences[i], probs[i])):
              ax.text(
                  word_pos,
                  0.5,
                  word,
                  horizontalalignment="left",
                  verticalalignment="center",
                  fontsize=8,
                  color=cmap(norm(prob)),
                  transform=ax.transAxes,
                  fontweight=700,
              )
              word_pos += 0.0036 * (
                  len(word) + 1
              )  # to move the word for the next iter
          ax.axis("off")
      plt.subplots_adjust(wspace=0, hspace=0)
      plt.tight_layout()
      plt.savefig("test_sentences.png")
  
file_path: finetune/finetune/datasets/stanford_sentiment_treebank_explain.py
imports: import logging
  import numpy
  from sklearn.model_selection import train_test_split
  import matplotlib.pyplot
  from matplotlib.patches import Rectangle
  import matplotlib.colors
  from finetune import Classifier
  from finetune.datasets.stanford_sentiment_treebank import StanfordSentimentTreebank
  from finetune.base_models.gpt.model import GPTModel
label_desc: Use image node_id 1 for calling a global function with example usage: sentences_heatmap(sentences, probs, clf) without return types