I need to set the diagonal to 0 before taking the sum
reduce[torch.eye(n).byte().cuda()] = 0

Is what I am doing right now, is there another, more efficient way of doing it?
edit:
am currently creating an array with the indexes, so I dont have to call .eye every time, then using that list as an index to overwrite the diagonal
diagArray = np.array([np.array(range(0,n)),np.array(range(0,n))])