Some code seems to be missing from your example. For instance, the variable new_loss is not initialized in your snipped.
For a start, you can try to remove all code not directly related to backward/forward passes. That will definitively make debugging easier.