code: def get_log_frequency_spectrogram_layer(
      input_shape=None,
      n_fft=2048,
      win_length=None,
      hop_length=None,
      window_name=None,
      pad_begin=False,
      pad_end=False,
      sample_rate=22050,
      log_n_bins=84,
      log_f_min=None,
      log_bins_per_octave=12,
      log_spread=0.125,
      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="log_frequency_spectrogram",
  ):
      """A function that returns a log-frequency STFT layer, which is a `keras.Sequential` model consists of
      `STFT`, `Magnitude`, `ApplyFilterbank(_log_filterbank)`, and optionally `MagnitudeToDecibel`.
  
      Args:
          input_shape (None or tuple of integers): input shape of the model 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`.
          sample_rate (int): sample rate of the input audio
          log_n_bins (int): number of the bins in the log-frequency filterbank
          log_f_min (float): lowest frequency of the filterbank
          log_bins_per_octave (int): number of bins in each octave in the filterbank
          log_spread (float): spread constant (Q value) in the log filterbank.
          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 mel spectrogram.
              `'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:
          Log-frequency spectrogram is similar to melspectrogram but its frequency axis is perfectly linear to octave scale.
          For some pitch-related applications, a log-frequency spectrogram can be a good choice.
  
      Example:
          ::
  
              input_shape = (2048, 2)  # stereo signal, audio is channels_last
              logfreq_stft_mag = get_log_frequency_spectrogram_layer(
                  input_shape=input_shape, n_fft=1024, return_decibel=True,
                  log_n_bins=84, input_data_format='channels_last', output_data_format='channels_last')
              model = Sequential()
              model.add(logfreq_stft_mag)
              # now the shape is (batch, n_frame=3, n_bins=84, n_ch=2) because output_data_format is 'channels_last'
              # 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()
  
      _log_filterbank = backend.filterbank_log(
          sample_rate=sample_rate,
          n_freq=n_fft // 2 + 1,
          n_bins=log_n_bins,
          bins_per_octave=log_bins_per_octave,
          f_min=log_f_min,
          spread=log_spread,
      )
      kwargs = {
          "sample_rate": sample_rate,
          "n_freq": n_fft // 2 + 1,
          "n_bins": log_n_bins,
          "bins_per_octave": log_bins_per_octave,
          "f_min": log_f_min,
          "spread": log_spread,
      }
  
      stftm_to_loggram = ApplyFilterbank(
          type="log",
          filterbank_kwargs=kwargs,
          data_format=output_data_format,
      )
  
      layers = [waveform_to_stft, stft_to_stftm, stftm_to_loggram]
  
      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 3 for calling a global function with example usage: get_log_frequency_spectrogram_layer(input_shape, n_fft, win_length, hop_length, window_name, pad_begin, pad_end, sample_rate, log_n_bins, log_f_min, log_bins_per_octave, log_spread, return_decibel, db_amin, db_ref_value, db_dynamic_range, input_data_format, output_data_format, name) and returns: Sequential