spanev:

ion in mask? Which gradient should be 1? d.grad will be 1 since we run backward on it.
In d = torch.mean(masked_input) all the inputs (even the zero’d ones) will contribute to the mean, so the final gradients will be 1/(16*16) on the non masked elements, and 0 on the masked/zero’d ones.


I means I want to set grad on the outside ROI to zero, it means we will untouch the region