Variational foundations of online backpropagation