seperating out the average and plain apis in stochastic_gradient.py