Thanks for the update!
Do you require gradients in the samples themselves or are you also training the network used in the sampler?
Also, your current forward method is using the no_grad context manager. I assume the forward is used in the sampler network?
If so, does the code also raise the error, if you call detach_().requires_grad_() outside of the forward on the returned samples?