title: equivalent of enumerate in tensorflow to use index in tf.map_fn
body: <p>I have a tensor that I process row by row using <code>tf.map_fn</code>. Now I want to include the index as an argument in the function that I am passing to <code>tf.map_fn</code>. In numpy I could use <code>enumerate</code> to get that information and pass it in my lambda function. Here's an example in numpy where I add 0 to the first row, 1 to the second row and so on:</p>
  
  <pre><code>a = np.array([[2, 1], [4, 2], [-1, 2]])
  
  def some_function(x, i):
      return x + i
  
  res = map(lambda (i, row): some_function(row, i), enumerate(a))
  print(res)
  
  &gt; [array([2, 1]), array([5, 3]), array([1, 4])]
  </code></pre>
  
  <p>I haven't been able to find an equivalent to <code>enumerate</code> in tensorflow though and I don't know how I can achieve the same result in tensorflow. Does someone know what to use to make it work in tensorflow? Here's a sample code where I add 1 to each row of <code>a</code>:</p>
  
  <pre><code>import tensorflow as tf
  
  a = tf.constant([[2, 1], [4, 2], [-1, 2]])
  
  with tf.Session() as sess:
      res = tf.map_fn(lambda row: some_function(row, 1), a)
      print(res.eval())
  
  &gt; [[3 2]
     [5 3]
     [0 3]]
  </code></pre>
  
  <p>Thanks to anyone who can help me with this problem.</p>