title: Create indices for a 2D Tensor
body: <p>I'm trying to do something like this:</p>
  
  <p>Suppose the input Tensor is a <code>(2, 3)</code> Tensor with the value like:</p>
  
  <pre><code>[[1 2]
   [3 4]
   [5 6]]
  </code></pre>
  
  <p>I am flattening the 2D Tensor into 1D by doing:</p>
  
  <pre><code>input = tf.reshape(input, [-1])
  </code></pre>
  
  <p>So the input now becomes <code>[1 2 3 4 5 6]</code>.</p>
  
  <p>But I also create a 1D Tensor that indexes the previous Tensor, so the desired output is <code>[0 0 1 1 2 2]</code>. How should I create this Tensor in TF?</p>
  
  <p>In general, if the input Tensor has a shape of <code>(X, Y)</code>. I would like to create a 1D Tensor that looks like:</p>
  
  <pre><code>[0 0 0 ... 0 1 ....1 2 ... 2 ... X-1 ... X-1]
  </code></pre>
  
  <p>where each value is repeated Y - 1 times.</p>