For your case of custom mean and std, you can use torch.distributions.Normal()
Init signature:
tdist.Normal(loc, scale, validate_args=None)
Docstring:
Creates a normal (also called Gaussian) distribution parameterized by loc and scale.
Args:
loc (float or Tensor): mean of the distribution (often referred to as mu)
scale (float or Tensor): standard deviation of the distribution (often referred to as sigma)
Here's an example:
In [32]: import torch.distributions as tdist
In [33]: n = tdist.Normal(torch.tensor([4.0]), torch.tensor([0.5]))
In [34]: n.sample((2,))
Out[34]:
tensor([[ 3.6577],
[ 4.7001]])