What do you want to do accomplish ?
The output you gave as an example is not a tensor, as it does not have the same number of elements in each “row”.
You can try torch.nonzero(x), or x.ne(0) (meaning ‘not equal’).
One of the two solutions will probably suit your needs.