Thx for your reply, Frank.  Sorry for my poor English.
First, let me explain what I’m doing in this two layer, I have a logits which is a result of a classification, and the fake or synthetic label is the target, and I used to kl_dive to compute the divergence between them. Than I used to gradient to update the logits, than I used the new logits to compute the cross entropy between the new logits and the right label(y_qry). After that, I used the new gradient of the synthetic label to update the synthetic label.

I believe what you are seeing is that  F.kl_div()  doesn’t track gradients
with respect to its second argument (your  label ). (I think this is a
“feature” in the interest of efficiency.)

Second, I used the auto.grad function to directly compute the gradient of label, it can track gradients with respect to its arguments normally. But I compute the gradient of label in the cross entropy loss, it can not track. Is this possible that it can not track an tensor in another loss function ?