I think you want x = x.reshape(n, c ,h * w).(log_)softmax(-1).view(n, c, h, w) if you want logsoftmax or x = x / x.sum((-1, -2), keepdim=True) if you have positive values and want to normalize.
Best regards
Thomas