title: How to sample efficiently from a list like [[0,1],[0,6],[0,7],[1,4],[1,8]], ideally in pytorch (so this will be a tensor)
body: <p>I have a tensor that looks like</p>
  
  <pre><code>[[0,1],
   [0,6],
   [0,7],
   [1,4],
   [1,8],
   [2,5],
   [2,7]]
  </code></pre>
  
  <p>so the first column is always a non-decreasing sequence from 0 to N (N is fixed), and the second column is some integer (within a fixed range). For the sampling, I want to obtain one sample from the second column for each distinct number in the first column. In this example, I want to get one sample from [1,6,7] for 0,  one sample from [4,8] for 1, and one sample from [5,7] for 2, and valid examples of samples can be [1,8,7], [7,8,7], etc. </p>