Implementing general dropout

I want to implement general dropout. For example, Suppose I have 100 neurons in a layer, let them be n1, n2 … n100. Now if i call dropout with parameter value 2, then it should drop neurons in a group of 2, i.e, it should either drop both n1 and n2, or both n3 and n4 … both n99 and n100.

What is the best way I can implement this?

F.dropout2d(x.view(-1,50,2).unsqueeze(3), 0.5, self.training).view(-1,100)