title: How can I select single indices over a dimension in pytorch?
body: <p>Assume I have a tensor <code>sequences</code> of shape <code>[8, 12, 2]</code>. Now I would like to make a selection of that tensor for each first dimension which results in a tensor of shape <code>[8, 2]</code>. The selection over dimension 1 is specified by indices stored in a long tensor <code>indices</code> of shape <code>[8]</code>.</p>
  
  <p>I tried this, however it selects each index in <code>indices</code> for each first dimension in <code>sequences</code> instead of only one.</p>
  
  <pre><code>sequences[:, indices]
  </code></pre>
  
  <p>How can I make this query without a slow and ugly <code>for</code> loop?</p>