def realimag(mag, phase):
    """
    Combine a magnitude spectrogram and a phase spectrogram to a complex-valued spectrogram with shape (*, 2)
    """
    spec_real = mag * torch.cos(phase)
    spec_imag = mag * torch.sin(phase)
    spec = torch.stack([spec_real, spec_imag], dim=-1)
    return spec

    Combine a magnitude spectrogram and a phase spectrogram to a complex-valued spectrogram with shape (*, 2)
    
train/speech_enhancement/models/frcrn/utils.py