title: slice 2d tensor specified by index tensor in tensorflow
body: <p>I have a 2d tensor and I want to extract few starting elements from each row.<br>
  I have column index (for each row) upto which elements must be captured.<br>
  Note that column index is different for different rows.<br>
  Following example makes it concreate:<br>
  2d tensor is:  </p>
  
  <pre><code>[[4 2 4 4 1 1 1 1 1 1 1 1 1 1 1 1]  
   [4 4 4 4 4 4 4 1 1 1 1 1 1 1 1 1]  
   [4 4 4 5 4 4 4 1 1 1 1 1 1 1 1 1]  
   [4 4 1 4 4 4 4 1 1 1 1 1 1 1 1 1]  
   [4 4 4 4 6 4 4 8 8 1 1 1 1 1 1 1]  
   [3 9 9 9 9 9 9 1 1 1 1 1 1 1 1 1]  
   [3 9 9 9 9 9 9 1 1 1 1 1 1 1 1 1]  
   [1 9 9 9 9 9 9 1 1 1 1 1 1 1 1 1]  
   [3 9 4 9 9 9 9 1 1 1 1 1 1 1 1 1]  
   [3 9 9 6 9 9 9 1 1 1 1 1 1 1 1 1]]  
  </code></pre>
  
  <p>and the index array is:  </p>
  
  <pre><code>[4 7 7 7 9 7 7 7 7 7]
  </code></pre>
  
  <p>How to get following array from above index array:  </p>
  
  <pre><code>[[4 2 4 4 ]  
   [4 4 4 4 4 4 4 ]  
   [4 4 4 5 4 4 4]  
   [4 4 1 4 4 4 4]  
   [4 4 4 4 6 4 4 8 8]  
   [3 9 9 9 9 9 9 ]  
   [3 9 9 9 9 9 9 ]  
   [1 9 9 9 9 9 9 ]  
   [3 9 4 9 9 9 9 ]  
   [3 9 9 6 9 9 9 ]]  
  </code></pre>