I use torch.Beta to get some variables follow beta distribution

My problem is should I write the gradient backpropagation myself or the system can automatically perform the BP for the sampling from the distribution? Could anyone help me?