I called gc.collect manually just for testing and for clarifying the problem. Original code does not call gc.collect manually.
The important thing is that garbage is created. Even if gc.collect is not called manually, because garbage continues to be created, gc.collect is called periodically (perhaps when memory is insufficient), which makes training slow down.