code: def get_stft_magnitude_layer(
      input_shape=None,
      n_fft=2048,
      win_length=None,
      hop_length=None,
      window_name=None,
      pad_begin=False,
      pad_end=False,
      return_decibel=False,
      db_amin=1e-5,
      db_ref_value=1.0,
      db_dynamic_range=80.0,
      input_data_format="default",
      output_data_format="default",
      name="stft_magnitude",
  ):
      """A function that returns a stft magnitude layer.
      The layer is a `keras.Sequential` model consists of `STFT`, `Magnitude`, and optionally `MagnitudeToDecibel`.
  
      Args:
          input_shape (None or tuple of integers): input shape of the model. Necessary only if this melspectrogram layer is
              is the first layer of your model (see `keras.model.Sequential()` for more details)
          n_fft (int): number of FFT points in `STFT`
          win_length (int): window length of `STFT`
          hop_length (int): hop length of `STFT`
          window_name (str or None): *Name* of `tf.signal` function that returns a 1D tensor window that is used in analysis.
              Defaults to `hann_window` which uses `tf.signal.hann_window`.
              Window availability depends on Tensorflow version. More details are at `kapre.backend.get_window()`.
          pad_begin (bool): Whether to pad with zeros along time axis (length: win_length - hop_length). Defaults to `False`.
          pad_end (bool): whether to pad the input signal at the end in `STFT`.
          return_decibel (bool): whether to apply decibel scaling at the end
          db_amin (float): noise floor of decibel scaling input. See `MagnitudeToDecibel` for more details.
          db_ref_value (float): reference value of decibel scaling. See `MagnitudeToDecibel` for more details.
          db_dynamic_range (float): dynamic range of the decibel scaling result.
          input_data_format (str): the audio data format of input waveform batch.
              `'channels_last'` if it's `(batch, time, channels)`
              `'channels_first'` if it's `(batch, channels, time)`
              Defaults to the setting of your Keras configuration. (tf.keras.backend.image_data_format())
          output_data_format (str): the data format of output melspectrogram.
              `'channels_last'` if you want `(batch, time, frequency, channels)`
              `'channels_first'` if you want `(batch, channels, time, frequency)`
              Defaults to the setting of your Keras configuration. (tf.keras.backend.image_data_format())
          name (str): name of the returned layer
  
      Note:
          STFT magnitude represents a linear-frequency spectrum of audio signal and probably the most popular choice
          when it comes to audio analysis in general. By using magnitude, this layer discard the phase information,
          which is generally known to be irrelevant to human auditory perception.
  
      Note:
          For audio analysis (when the output is tag/label/etc), we'd like to recommend to set `return_decibel=True`.
          Decibel scaling is perceptually plausible and numerically stable
          (related paper: `A Comparison of Audio Signal Preprocessing Methods for Deep Neural Networks on Music Tagging <https://arxiv.org/abs/1709.01922>`_)
          Many music, speech, and audio applications have used this log-magnitude STFT, e.g.,
          `Learning to Pinpoint Singing Voice from Weakly Labeled Examples <https://wp.nyu.edu/ismir2016/wp-content/uploads/sites/2294/2016/07/315_Paper.pdf>`_,
          `Joint Beat and Downbeat Tracking with Recurrent Neural Networks <https://archives.ismir.net/ismir2016/paper/000186.pdf>`_,
          and many more.
  
          For audio processing (when the output is audio signal), it might be better to use STFT as it is (`return_decibel=False`).
          Example: `Singing voice separation with deep U-Net convolutional networks <https://openaccess.city.ac.uk/id/eprint/19289/>`_.
          This is because decibel scaling is has some clipping at the noise floor which is irreversible.
          One may use `log(1+X)` instead of `log(X)` to avoid the clipping but it is not included in Kapre at the moment.
  
      Example:
          ::
  
              input_shape = (2048, 1)  # mono signal, audio is channels_last
              stft_mag = get_stft_magnitude_layer(input_shape=input_shape, n_fft=1024, return_decibel=True,
                  input_data_format='channels_last', output_data_format='channels_first')
              model = Sequential()
              model.add(stft_mag)
              # now the shape is (batch, ch=1, n_frame=3, n_freq=513) because output_data_format is 'channels_first'
              # and the dtype is float
  
      """
      backend.validate_data_format_str(input_data_format)
      backend.validate_data_format_str(output_data_format)
  
      stft_kwargs = {}
      if input_shape is not None:
          stft_kwargs["input_shape"] = input_shape
  
      waveform_to_stft = STFT(
          **stft_kwargs,
          n_fft=n_fft,
          win_length=win_length,
          hop_length=hop_length,
          window_name=window_name,
          pad_begin=pad_begin,
          pad_end=pad_end,
          input_data_format=input_data_format,
          output_data_format=output_data_format,
      )
  
      stft_to_stftm = Magnitude()
  
      layers = [waveform_to_stft, stft_to_stftm]
      if return_decibel:
          mag_to_decibel = MagnitudeToDecibel(
              ref_value=db_ref_value,
              amin=db_amin,
              dynamic_range=db_dynamic_range,
          )
          layers.append(mag_to_decibel)
  
      return Sequential(layers, name=name)
  
file_path: kapre/kapre/composed.py
imports: from tensorflow import keras
  from tensorflow.keras import Sequential, Model
  from .time_frequency import STFT, InverseSTFT, Magnitude, Phase, MagnitudeToDecibel, ApplyFilterbank, ConcatenateFrequencyMap
  from .None import backend
  from .backend import _CH_FIRST_STR, _CH_LAST_STR, _CH_DEFAULT_STR
label_desc: Use image node_id 1 for calling a global function with example usage: get_stft_magnitude_layer(input_shape, n_fft, win_length, hop_length, window_name, pad_begin, pad_end, return_decibel, db_amin, db_ref_value, db_dynamic_range, input_data_format, output_data_format, name) and returns: Sequential