python – Initialize weights in pytorch with customized weight?

I want to initialize the weights of my neural network with parameters samples from a specific distribution, that is not already present in nn.init module. Let’s say for example a beta distribution.

I saw that you can use the method described there: Custom weight initialization in PyTorch

But there you need to use the nn.init. What is an elegant way to initialize weights from a distribution that I specify