Note that ctx is not an instance of Function but rather a “backward context” object, so this won’t work. What you could do is a thing like
def MyFunc(extra_inputs):
    class MyFuncFn(torch.autograd.Function):
        @staticmethod
        def foward(ctx, input):
            ...
        ...
    return MyFuncFn.apply

or so, but I’d have doubts whether that’s really worth it (relative to using functools.partial or so).
I tend to use mutuable types (e.g. dictionaries) for stats.
Best regards
Thomas