Sorry, didn’t have a chance to look at your code, but really quickly, if this is in a model, maybe you could possibly use
with pm.Model() as model:
lamda = 3
k = 2
J = pm.Poisson("J", lamda)
nc_chi2 = pm.ChiSquared("nc_chi2", nu=k+2*J)