You could try the following:
a = torch.randn(10, 10)
step = 1 + (np.cumprod(a.shape[:-1])).sum()
a.view(-1)[::step] = 0
a.view(10, 10)

EDIT: Sorry, I just realized, this formula might lead to wrong results, when the dimension sizes differ.
What is your definition of diagonal? Each diagonal of the square matrix [N, N]?