How to free the graph after create_graph=True

If you check the docs, when you do create_graph=True this means retain_graph will take this True, since it defaults to the value of create_graph.

If you do create_graph=True, you should set also retain_graph=False to release the memory.