Return the indices of the elements of a that are not zero nor masked, as a tuple of arrays.
There are as many tuples as dimensions of a, each tuple contains the indices of the non-zero elements in that dimension. The corresponding non-zero values can be obtained with a[a.nonzero()].
To group the indices by element, rather than dimension, use instead: transpose(a.nonzero()).
The result of this is always a 2d array, with a row for each non-zero element.