Well, so

if you have inputs that are differentiable (and I take it you have), you can use these instead of the dummy parameter,
if you don’t have inputs that are differentiable (which is why you need the dummy), you don’t need an autograd.Function.

What I think might make the examples easier is move from passing in a module to passing in a (python) function that doesn’t use global variables instead.
Then you can have the parametrized function and the parameters as part of the inputs in functional and it’ll work with the recipe above. I’m doing something like that (but not with sampling and taking derivatives of the density or so) in my Implicit Function 5 notebook. (Nowadays you can do the backward that I’m doing in the forward there in the backward, but I did that a looong time ago.)
Best regards
Thomas