How can I do online Hard example Mining?
I compute loss for the whole batch, then compute the squared distances between prediction and target and sort them with topK.
But How could i use the  loss.backward() but only for specific indexes?  how to implement it in Pytorch?