Modelling Sampling Distributions of Test Statistics with Autograd