title: How to index a 3-D tensor with 2-D tensor in Tensorflow?
body: <p>I am trying to use a 2-D tensor to index a 3-D tensor in Tensorflow. For example, I have <code>x</code> of shape <code>[2, 3, 4]</code>:</p>
  
  <pre><code>[[[ 0,  1,  2,  3],
    [ 4,  5,  6,  7],
    [ 8,  9, 10, 11]],
  
   [[12, 13, 14, 15],
    [16, 17, 18, 19],
    [20, 21, 22, 23]]]
  </code></pre>
  
  <p>and I want to index it with another tensor <code>y</code> of shape <code>[2, 3]</code>, where each element of <code>y</code> index the last dimension of <code>x</code>. For example, if we have <code>y</code> like:</p>
  
  <pre><code>[[0, 2, 3],
   [1, 0, 2]]
  </code></pre>
  
  <p>The output should of shape <code>[2, 3]</code>:</p>
  
  <pre><code>[[0, 6, 11],
   [13, 16, 22]]
  </code></pre>