torch.nonzero — PyTorch 1.10.1 documentation
pytorch.org › docs › stableIf input has n n n dimensions, then the resulting tuple contains n n n tensors of size z z z, where z z z is the total number of non-zero elements in the input tensor. As a special case, when input has zero dimensions and a nonzero scalar value, it is treated as a one-dimensional tensor with one element. Parameters. input – the input tensor.