I don’t know if I will be able to paste a minimal snippet. This post was created with the part of nn.ModuleList containing Nones.
I have tried to measure times again:
Withouth tracing:
CPU times: user 12.8 s, sys: 1.41 s, total: 14.2 s
Wall time: 2.32 s

Scripted First Iteration:
CPU times: user 15 s, sys: 1.77 s, total: 16.8 s
Wall time: 4.64 s

Scripted Second Iteration:
CPU times: user 5min 8s, sys: 1.14 s, total: 5min 9s
Wall time: 5min

Scripted Third Iteration:
CPU times: user 11 s, sys: 1.18 s, total: 12.2 s
Wall time: 2.02 s