Render 2d gaussian such that one can take gradient with respect to the mean

I need to render a 2d gaussian and still be able to differentiate with respect to the 2d mean, which has type float. The standard deviation of the gaussian can be constant. Same for the size of the matrix that is generated.
Any idea how to do this in pytorch?

**CLARIFICATION: **

I need a function draw2dGaussian(mean2d) which returns a 2d matrix M. The matrix M will show a discretized 2d gaussian centered at the location mean2d. Note that mean2d is a pair of 2 floats. The matrix M will be 0 at the points far enough from the mean2d.

The requirement of this function draw2dGaussian is that it has to be differentiable with respect to mean2d.

I think openDR http://files.is.tue.mpg.de/black/papers/OpenDR.pdf might be able to offer such a function, but I was wondering if somebody had a simpler solution.