Could you explain, why you need a list in the code?
Would it be possible to use a tensor instead?
Regarding point 1: if you can write all your operations using PyTorch methods, Autograd will be able to calculate the gradients in the backward call automatically.