title: Count unique slices in a ndarray
body: <p>I have a 3D integer tensor <code>X</code> with <code>X.shape=(m, n, k)</code> </p>
  
  <p>I'd like to treat <code>X</code> as a <code>(m, n)</code> matrix with entries that are <code>k</code> sized integer vectors and count how many such unique entries are in each row.
  So for example</p>
  
  <pre><code>&gt;&gt;&gt; X
  array([[[0, 1, 2],
          [0, 1, 2],
          [1, 2, 3],
          [1, 2, 3]],
         [[3, 4, 5],
          [4, 5, 6],
          [5, 6, 7],
          [6, 7, 8]]])
  &gt;&gt;&gt; X.shape
  (2, 4, 3)
  
  &gt;&gt;&gt; count_unique(X)
  [2, 4]
  </code></pre>
  
  <p>Since in the first row of the tensor there are 2 unique vectors and in the second row there are 4</p>
  
  <p>Bonus points for returning the actual unique vectors, e.g. </p>
  
  <pre><code>&gt;&gt;&gt; get_unique(X)
  [[[0, 1, 2], [1, 2, 3]],\
  [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8]]]
  </code></pre>
  
  <p>My solution (partially vectorized) for the first question</p>
  
  <pre><code>count_unique = lambda X: [len(np.unique(row, axis=0)) for row in X]
  </code></pre>