def apply_masks(spectrogram, masks):
    """
    Takes in a signal spectrogram and apply a set of T-F masks to it to recover
    the sources.
    Inputs:
        spectrogram: Numpy array of shape (T, F) containing the complex
                     spectrogram of the signal to mask.
        masks: Numpy array of shape (T, F, sources) containing the T-F masks for
               each source.
    Returns:
        masked_spectrograms: Numpy array of shape (sources, T, F) containing
                             the masked complex spectrograms for each source.
    """
    num_sources = masks.shape[2]

    masked_specs = [masks[:,:,i]*spectrogram for i in range(num_sources)]

    return masked_specs