moved mini-batch code to demo.py