You are mixing two difference things:

Writing own module using autograd (this you want)
Extending autograd by your own function, because ex. torch doesn’t have Bernoulli distribution (you are doing that)

So if you want to create Gaussian distribution and torch have enough function to code it, you should use nn.Module as a base (Function require to have backward pass coded by user)
Also in such case you are able to test gradient, but it would return True because  autograd calculate it:)
So, in summary, use nn.Module if you are not using any special-external library (like scipy, nlp etc.)
So code for your function should look like that:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import torch
import torch.nn as nn
from torch.autograd import Variable
from torch.autograd import Function
from torch.autograd import gradcheck

class Gaussian(nn.Module):
    def forward(self, input,sigma,center):
        dist1=center-input
        dist=torch.pow(dist1,2)
        dist2=torch.sum(dist,1)
        sigma2=torch.pow(sigma,2)
        dist=-1/2*sigma2*dist2
        output=torch.exp(dist)
        return output 



input =(Variable(torch.randn(10).double(), requires_grad=True), Variable(torch.randn(20).double(), requires_grad=True),
        Variable(torch.randn(20,10).double(), requires_grad=True))

test = gradcheck(Gaussian().forward, input, eps=1e-6, atol=1e-4)
print(test)

# for to use this module
g     = Gaussian()
data = g(*input)
loss = data.sum() # need to be a scalar
loss.backward()