def apply_scaler_to_mel(scaler, mel, inverse=False):
    """
    Function for applying a fitted normalizer/scaler (sklearn.preprocessing) to a single mel spectrogram.
    :param scaler (sklearn.preprocessing obj): scaler that is applied
    :param mel (numpy.ndarray): mel spectrogram

    :return: scaled mel spectrogram (numpy.ndarray)
    """
    shape_ = mel.shape
    flat_mel = mel.flatten().reshape(-1, 1)
    if inverse:
        scaled_flat_mel = scaler.inverse_transform(flat_mel)
    else:
        scaled_flat_mel = scaler.transform(flat_mel)
    scaled_mel = scaled_flat_mel.reshape(shape_)
    return scaled_mel