If a is a Tensor, then a.triu(k=1) will get the upper triangular part above the first diagonal. But if a is a Variable, I got the below error:
TypeError: triu() got an unexpected keyword argument 'k'
It seems that for Variables. the appropriate argument name is diagonal_idx .
It would be nice if both have the same argument names.