How to hold residual-dependent term constant in Jacobian calculation

Hello,

This is a pretty general question related to this post https://fenicsproject.discourse.group/t/implicit-explicit-schemes-in-stabilization-methods/8394/2. I am implementing a viscosity discontinuity capturing term.

My question is how do I hold a residual-dependent variable constant during the Jacobian calculation? If say
J = ufl.derivative(Res, u)
where the residual is
Res = Res_Gal + Res_Stab
and the term in question is say NU in
Res_Stab = ufl.inner(NU * ufl.grad(w), ufl.grad(u))*dx
is a function of
StrongResidual = SomeFunction(u).

Thanks!