Learning over functions, distributions and dynamics via stochastic optimization