code: def plot_spectrogram(
      plt,
      spec,
      mode="db",
      fs=None,
      frame_shift=None,
      bottom=True,
      left=True,
      right=True,
      top=False,
      labelbottom=True,
      labelleft=True,
      labelright=True,
      labeltop=False,
      cmap="inferno",
  ):
      """Plot spectrogram using matplotlib.
  
      Args:
          plt (matplotlib.pyplot): pyplot object.
          spec (numpy.ndarray): Input stft (Freq, Time)
          mode (str): db or linear.
          fs (int): Sample frequency. To convert y-axis to kHz unit.
          frame_shift (int): The frame shift of stft. To convert x-axis to second unit.
          bottom (bool):Whether to draw the respective ticks.
          left (bool):
          right (bool):
          top (bool):
          labelbottom (bool):Whether to draw the respective tick labels.
          labelleft (bool):
          labelright (bool):
          labeltop (bool):
          cmap (str): Colormap defined in matplotlib.
  
      """
      spec = np.abs(spec)
      if mode == "db":
          x = 20 * np.log10(spec + np.finfo(spec.dtype).eps)
      elif mode == "linear":
          x = spec
      else:
          raise ValueError(mode)
  
      if fs is not None:
          ytop = fs / 2000
          ylabel = "kHz"
      else:
          ytop = x.shape[0]
          ylabel = "bin"
  
      if frame_shift is not None and fs is not None:
          xtop = x.shape[1] * frame_shift / fs
          xlabel = "s"
      else:
          xtop = x.shape[1]
          xlabel = "frame"
  
      extent = (0, xtop, 0, ytop)
      plt.imshow(x[::-1], cmap=cmap, extent=extent)
  
      if labelbottom:
          plt.xlabel("time [{}]".format(xlabel))
      if labelleft:
          plt.ylabel("freq [{}]".format(ylabel))
      plt.colorbar().set_label("{}".format(mode))
  
      plt.tick_params(
          bottom=bottom,
          left=left,
          right=right,
          top=top,
          labelbottom=labelbottom,
          labelleft=labelleft,
          labelright=labelright,
          labeltop=labeltop,
      )
      plt.axis("auto")
  
imports: import argparse
  import copy
  import json
  import logging
  import os
  import shutil
  import tempfile
  import numpy
  import torch
label_desc: Use image node_id 18 for calling a global function with example usage: plot_spectrogram(plt, spec, mode, fs, frame_shift, bottom, left, right, top, labelbottom, labelleft, labelright, labeltop, cmap) without return types