How do I make a mask of diagonal matrix, but starting from the 2nd column?
So here is what I can get with torch.eye(3,4) now

The matrix I get: 

[[1, 0, 0, 0],
 [0, 1, 0, 0],
 [0, 0, 1, 0]]


Is there any (easy)way to transform it, or make such a mask in this format:

The matrix I want:

[[0, 1, 0, 0],
 [0, 0, 1, 0],
 [0, 0, 0, 1]]


You can do it by using torch.diagonal and specifying the diagonal you want:

&gt;&gt;&gt; torch.diag(torch.tensor([1,1,1]), diagonal=1)[:-1]

tensor([[0, 1, 0, 0],
        [0, 0, 1, 0],
        [0, 0, 0, 1]])



  
  If :attr:diagonal = 0, it is the main diagonal.
  If :attr:diagonal > 0, it is above the main diagonal.
  If :attr:diagonal &lt; 0, it is below the main diagonal.
  

