DLS course 4 week 4 exercise 6 train_step

And I believe reading these two posts would also benefit you.
Post 1
Post 2