Solved by KFrank in post #2 
              
              
                Hi Adonai! 

You may use torch.diagonal() to get a modifiable view into your matrix of 
the desired diagonals, and then use zero_() to zero them out: 
>>> torch.__version__
'1.7.1'
>>> A = torch.arange (36).view ((6, 6))
>>> A
tensor([[ 0,  1,  2,  3,  4,  5],
        [ 6,  7,  8,  9, 10, 11],
     …