triu_indices(row: int, col: int | None = None, offset: int = 0, dtype: DTypeLike = None, device: DeviceLike = None)Indices of the upper-triangular part of an (row, col) matrix.
Mirrors tril_indices with the inequality flipped — keeps
entries where j - i >= offset.
Parameters
rowintNumber of rows in the matrix being indexed.
colint= NoneNumber of columns.
None (default) → col = row.offsetint= 0Diagonal offset.
0 (default) = main diagonal,
positive = exclude diagonals close to the main one,
negative = include diagonals below it.dtypeDTypeLike= NoneOutput dtype (default: int64).
deviceDeviceLike= NonePlacement of the result.
Returns
TensorShape (2, N). Row 0 holds row indices, row 1 holds
column indices, in row-major order.