title: Count nonzeros element along an axis in pytorch
body: <p>I have a <code>(32x750)</code> tensor</p>
  
  <pre><code>tensor([[ 0.0000,  0.0000,  0.0000,  ...,  0.0000,  0.0000,  0.0043],
          [ 0.0000,  0.0000,  0.0000,  ...,  0.0000,  0.0000,  0.0043],
          [ 0.0000,  0.0044,  0.0000,  ...,  0.0044,  0.0000,  0.0000],
          ...,
          [ 0.0059,  0.0000,  0.0059,  ...,  0.0059,  0.0000,  0.0000],
          [ 0.0059,  0.0000,  0.0059,  ...,  0.0059,  0.0000,  0.0000],
          [ 0.0000,  0.0000,  0.0000,  ...,  0.0000,  0.0056,  0.0000]], device='cuda:0')
  </code></pre>
  
  <p>And I want to get  the number of nonzero elements along each rows. Something like that <code>[12  47 0 5 .... 8 7 50]</code>
  This <a href="https://discuss.pytorch.org/t/find-non-zero-elements-in-a-tensor/4493/2" rel="nofollow noreferrer">discussion</a> and <a href="https://stackoverflow.com/questions/44857373/find-number-of-non-zero-elements-in-a-tensor-along-an-aixs?rq=1">this</a> didn't solve my problem and concerned the number of nonzero elements for <code>1-D tensor.</code></p>
  
  <p>Thanks</p>