This looks like a fine implementation.
In the example you link,
y = w * x, so dy/dw = x.
However, in your context, you’d have something like
y = dropout(w * x + b) + ...
if dropout returns 0, the contribution of w is 0