Hi,
I guess you can do out = (torch.rand_like(a) - 0.05).sign().type_as(a) * a assuming a is a floating point number. This should select around 5% (the bigger the Tensor, the more precise it will be).