Yes  that is working great!! 
but i have two questions,
can you explain this part of your code: x.view(B, C, -1).mean(2)[:, :, None, None], I mean why did you use ‘None’?
Also do you know another way to do without  using torch.where ? for this project im using pytorch 0.3 and it does not have the where function