Hi,
The backward pass will clear all the buffers saved in the computational graph. So yes it can do that.
If you want to do the same, you need to make sure all references to the computational graph are gone. so del loss and del prob_trees here most likely.