Hi,
This package will return a dot graph: https://github.com/szagoruyko/pytorchviz 4
The objects are re-used because the first one goes out of scope and is free. But later one, since you redo an allocation of the same size, the same memory is returned to you (many allocator do caching for allocations of the same size).