Means size should be broadcastable to A
A = torch.rand(1,10,8,8)
Means = torch.mean(torch.mean(A,dim=3),dim=2).unsqueeze(-1).unsqueeze(-1)
Ones = torch.ones(A.size())
Zeros = torch.zeros(A.size())
Thresholded = torch.where(A > Means, Ones, Zeros)