googlebot:

k = x.size(0)
ls = [x[i] for i in range(k)]



Yes. So while requires_grad_ (always use the method!) could probably be supported, the list size here inherently is invisible to PyTorch in scripting.
The summary I always have is (I think it’s also in ch 15 of our book):

In tracing you can do anything you want, but the JIT won’t (and can’t) try to understand it all.
In scripting you can only do what the understands but the JIT will do it all.

This is inherent and to me it means that the second part would want to be extended in scope.
Best regards
Thomas