code: def plot_results(y_hat, y, ap, global_step, name_prefix):
      """Plot vocoder model results"""
  
      # select an instance from batch
      y_hat = y_hat[0].squeeze(0).detach().cpu().numpy()
      y = y[0].squeeze(0).detach().cpu().numpy()
  
      spec_fake = ap.melspectrogram(y_hat).T
      spec_real = ap.melspectrogram(y).T
      spec_diff = np.abs(spec_fake - spec_real)
  
      # plot figure and save it
      fig_wave = plt.figure()
      plt.subplot(2, 1, 1)
      plt.plot(y)
      plt.title("groundtruth speech")
      plt.subplot(2, 1, 2)
      plt.plot(y_hat)
      plt.title(f"generated speech @ {global_step} steps")
      plt.tight_layout()
      plt.close()
  
      figures = {
          name_prefix + "spectrogram/fake": plot_spectrogram(spec_fake),
          name_prefix + "spectrogram/real": plot_spectrogram(spec_real),
          name_prefix + "spectrogram/diff": plot_spectrogram(spec_diff),
          name_prefix + "speech_comparison": fig_wave,
      }
      return figures
  
file_path: TTS/TTS/vocoder/utils/generic_utils.py
imports: import re
  import torch
  import importlib
  import numpy
  from matplotlib import pyplot
  from TTS.tts.utils.visual import plot_spectrogram
label_desc: Use image node_id 2 for calling a global function with example usage: plot_results(y_hat, y, ap, global_step, name_prefix) and returns: figures