Well if they were used to compute the loss, they will contain the gradient value, not zero (unless your gradient is 0 but then it’s like it was not used to compute your loss).
But yes that would be a simple solution.
I am not sure to grasp what you why you want to do that, but from the description, it looks like what you want.