code: def amplitude_to_db(
      S: _ScalarOrSequence[_ComplexLike_co],
      *,
      ref: Union[float, Callable] = 1.0,
      amin: float = 1e-5,
      top_db: Optional[float] = 80.0,
  ) -> Union[np.floating[Any], np.ndarray]:
      """Convert an amplitude spectrogram to dB-scaled spectrogram.
  
      This is equivalent to ``power_to_db(S**2, ref=ref**2, amin=amin**2, top_db=top_db)``,
      but is provided for convenience.
  
      Parameters
      ----------
      S : np.ndarray
          input amplitude
  
      ref : scalar or callable
          If scalar, the amplitude ``abs(S)`` is scaled relative to ``ref``:
          ``20 * log10(S / ref)``.
          Zeros in the output correspond to positions where ``S == ref``.
  
          If callable, the reference value is computed as ``ref(S)``.
  
      amin : float > 0 [scalar]
          minimum threshold for ``S`` and ``ref``
  
      top_db : float >= 0 [scalar]
          threshold the output at ``top_db`` below the peak:
          ``max(20 * log10(S/ref)) - top_db``
  
      Returns
      -------
      S_db : np.ndarray
          ``S`` measured in dB
  
      See Also
      --------
      power_to_db, db_to_amplitude
  
      Notes
      -----
      This function caches at level 30.
      """
      S = np.asarray(S)
  
      if np.issubdtype(S.dtype, np.complexfloating):
          warnings.warn(
              "amplitude_to_db was called on complex input so phase "
              "information will be discarded. To suppress this warning, "
              "call amplitude_to_db(np.abs(S)) instead.",
              stacklevel=2,
          )
  
      magnitude = np.abs(S)
  
      if callable(ref):
          # User supplied a function to calculate reference power
          ref_value = ref(magnitude)
      else:
          ref_value = np.abs(ref)
  
      out_array = (
          magnitude if isinstance(magnitude, np.ndarray) else None
      )
      power = np.square(magnitude, out=out_array)
  
      db: np.ndarray = power_to_db(
          power, ref=ref_value**2, amin=amin**2, top_db=top_db
      )
      return db
  
imports: from __future__ import annotations
  import warnings
  import numpy
  import scipy
  import scipy.ndimage
  import scipy.signal
  import scipy.interpolate
  from numba import jit
  from .None import convert
  from .fft import get_fftlib
  from .audio import resample
  from .._cache import cache
  from ..None import util
  from ..util.exceptions import ParameterError
  from ..filters import get_window, semitone_filterbank
  from ..filters import window_sumsquare
  from numpy.typing import DTypeLike
  from typing import Any, Callable, Optional, Tuple, List, Union, overload
  from typing_extensions import Literal
  from .._typing import _WindowSpec, _PadMode, _PadModeSTFT, _SequenceLike, _ScalarOrSequence, _ComplexLike_co, _FloatLike_co
label_desc: Use image node_id 21 for calling a global function with example usage: amplitude_to_db(S) and returns: db