How to sample from normal distribution with torch::Tensor parameters in C++?

Hi everyone,

I am wondering how to sample from a Gaussian distribution with mean mu, and standard deviation std in C++. Ideally, I would like to do this given that mu and std are the outputs of a NN, hence, torch::Tensor objects, so that autograd can keep track of their operations.

Is there a method that satisfies these requirements?

In Python, I believe this is solved using torch.distributions.Normal.

Thank you.