I am trying to provide my own dropout mask in the forward function while defining a feed forward network.
For example
class Perceptron(torch.nn.Module):
    def __init__(self, mask):
        super(Perceptron, self).__init__()
        self.fc = nn.Linear(5,10)
       self.myDrop = MyDrop(mask)
def forward(self, x):
        output = self.fc(x)
        o1 = self.myDrop(output)
        return o1

Here mask is a vector consisting of 0’s and 1’s so accordingly the value of o1 with be either 0 or the existing values. In MyDrop() function i am simple just multiply the values of output with mask to get o1 as output. So here the gradient should all be zero for that node, but how does autogradd maintain this since i am not making custom Dropout class but instead using a mask through a simple function. So due backprop the graient will still be flow through those nodes even if the output has been made 0 using a mask?