code: def plot_spectrogram(
      spectrogram, ap=None, fig_size=(16, 10), output_fig=False
  ):
      if isinstance(spectrogram, torch.Tensor):
          spectrogram_ = spectrogram.detach().cpu().numpy().squeeze().T
      else:
          spectrogram_ = spectrogram.T
      spectrogram_ = (
          spectrogram_.astype(np.float32)
          if spectrogram_.dtype == np.float16
          else spectrogram_
      )
      if ap is not None:
          spectrogram_ = ap.denormalize(
              spectrogram_
          )  # pylint: disable=protected-access
      fig = plt.figure(figsize=fig_size)
      plt.imshow(spectrogram_, aspect="auto", origin="lower")
      plt.colorbar()
      plt.tight_layout()
      if not output_fig:
          plt.close()
      return fig
  
file_path: TTS/TTS/tts/utils/visual.py
imports: import librosa
  import matplotlib
  import numpy
  import torch
  import matplotlib.pyplot
  from TTS.tts.utils.text import phoneme_to_sequence, sequence_to_phoneme
label_desc: Use image node_id 2 for calling a global function with example usage: plot_spectrogram(spectrogram, ap, fig_size, output_fig) and returns: fig