Solved by albanD in post #11 
              
              
                retain_graph is only needed if you call backward again without calling forward again. If you only call things once, there is no need for it.