Solved by ptrblck in post #2 
              
              
                You could use F.unfold to create these 3x3 windows from the image and compute the std for each of these windows. 
You should be able to backpropagate through torch.std.