Hi @cj0741!
Hopefully this will help. Based on this link 6, we can sample entries from a Normal distribution in Pytorch for C++ as follows:
auto sample = torch::randn({1})*sigma + mu;

which is similar to the implementation found here 3 (I thank @glaringlee for having referred me to it a while ago).
Similarly, if you require to calculate the p.d.f., you could perhaps do it as follows, and also calculate the logprob with it after (see the implementation here 3):
auto pdf = (1.0 / (sigma * std::sqrt(2*M_PI))) * torch::exp(-0.5 * torch::pow((sample - mu) / sigma, 2));

Then, the logprob is:
auto log_prob = torch::log(pdf);

Feel free to ask any more questions!