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.
i ment to tensor, not list, im sorry
the question actually was:
when i write my own loss function (the one up here), and the loss gets a tensor of predictions and labels each time, should i sum all the distances?
You could sum them (and take the average afterwards) and it depends on your use case.
If you are not sure, if each loss creates valid gradients, you could check its .loss_fn.
If it’s some function other than a None value, it should work.