Could you make sure that the log operation returns valid outputs, e.g. that x is not zero?
Given that spec(x) can be zero, would it also be possible that complex_norm and mel return zeros?
If so, then torch.log(torch.zeros(1)) would return tensor([-inf]), which might raise this issue in the backward pass.