Another question, when should I use .detach() and .clone()?.
I understand .clone() also has backward gradient and .detach() has no gradient.
In the above loss function,

I have created a variable Center which needs a manual update. So, I believe it doesn’t requires gradient.
Comment If I am wrong

I have the features from the data, and here I am very confused, do I need to calculate gradient for the features or not?