thanks for reply.
Infact, I’m working with PINNs (physics informed neural network) I’m trying to solve PDE with neural network, In my loss function definition, we use gradient and divergence of the temperature to express the physic loss.
so those gradient above I’m talking about are  calculated in forward method of the method to retrun all physics items that the model calculate and used to define physic loss.
thanks