code: def specgram(
      x,
      NFFT=None,
      Fs=None,
      detrend=None,
      window=None,
      noverlap=None,
      pad_to=None,
      sides=None,
      scale_by_freq=None,
      mode=None,
  ):
      """
      Compute a spectrogram.
  
      Compute and plot a spectrogram of data in *x*.  Data are split into
      *NFFT* length segments and the spectrum of each section is
      computed.  The windowing function *window* is applied to each
      segment, and the amount of overlap of each segment is
      specified with *noverlap*.
  
      Parameters
      ----------
      x : array-like
          1-D array or sequence.
  
      %(Spectral)s
  
      %(PSD)s
  
      noverlap : int, default: 128
          The number of points of overlap between blocks.
      mode : str, default: 'psd'
          What sort of spectrum to use:
              'psd'
                  Returns the power spectral density.
              'complex'
                  Returns the complex-valued frequency spectrum.
              'magnitude'
                  Returns the magnitude spectrum.
              'angle'
                  Returns the phase spectrum without unwrapping.
              'phase'
                  Returns the phase spectrum with unwrapping.
  
      Returns
      -------
      spectrum : array-like
          2D array, columns are the periodograms of successive segments.
  
      freqs : array-like
          1-D array, frequencies corresponding to the rows in *spectrum*.
  
      t : array-like
          1-D array, the times corresponding to midpoints of segments
          (i.e the columns in *spectrum*).
  
      See Also
      --------
      psd : differs in the overlap and in the return values.
      complex_spectrum : similar, but with complex valued frequencies.
      magnitude_spectrum : similar single segment when *mode* is 'magnitude'.
      angle_spectrum : similar to single segment when *mode* is 'angle'.
      phase_spectrum : similar to single segment when *mode* is 'phase'.
  
      Notes
      -----
      *detrend* and *scale_by_freq* only apply when *mode* is set to 'psd'.
  
      """
      if noverlap is None:
          noverlap = (
              128  # default in _spectral_helper() is noverlap = 0
          )
      if NFFT is None:
          NFFT = 256  # same default as in _spectral_helper()
      if len(x) <= NFFT:
          _api.warn_external(
              "Only one segment is calculated since parameter "
              f"NFFT (={NFFT}) >= signal length (={len(x)})."
          )
  
      spec, freqs, t = _spectral_helper(
          x=x,
          y=None,
          NFFT=NFFT,
          Fs=Fs,
          detrend_func=detrend,
          window=window,
          noverlap=noverlap,
          pad_to=pad_to,
          sides=sides,
          scale_by_freq=scale_by_freq,
          mode=mode,
      )
  
      if mode != "complex":
          spec = spec.real  # Needed since helper implements generically
  
      return spec, freqs, t
  
imports: import functools
  from numbers import Number
  import numpy
  from matplotlib import _api, _docstring, cbook
label_desc: Use image node_id 11 for calling a global function with example usage: specgram(x, NFFT, Fs, detrend, window, noverlap, pad_to, sides, scale_by_freq, mode) and returns: spec,  freqs,  t