Solved by KFrank in post #4 
              
              
                Hi Talip! 

I think that torch.tril() and/or torch.triu() will be the key to what you want. 
Here is one specific approach: 
>>> torch.__version__
'1.6.0'
>>> n = 4
>>> a = 1
>>> torch.tril (torch.ones ((n, n)), a) * torch.triu (torch.ones ((n, n)), -a)
tensor([[1., 1., 0., 0.],
        [1., 1., 1.,…