First up thank you for the quick and detailed response!
I have tried executing the code at #Get all targets but have run into the following error:
TypeError: expected Tensor as element 0 in argument 0, but got int

which appears at the following line:
targets = torch.stack(targets)

When looking at targets, I noticed in my case it is full of ints, but torch.stack rather expects Tensors, if I understand it correctly?
Is this problematic or should I just use different functions to compute the samples weight?