Gradient is calculated when there is a computation graph. For example,
x --> linear(w, x) --> softmax().  Here, x, w could be potentially leaf nodes that require gradient.
In this same paradigm, when you add dx to loss function, it is just like you are adding a constant to the loss function. The weights of the NN doesn’t depend on the gradient and this dx doesn’t have any computation graph associated with it. So, I am not sure if x will be affected by this loss function at all.