title: TensorArray is not updating values from tf.cond()
body: <p>Using Tensorflow 1.3 and python 2.7</p>
  
  <p>TensorArray is not updating values from tf.cond(). </p>
  
  <pre><code>import tensorflow as tf
  temp1 = tf.TensorArray(dtype=tf.float32, size=0, dynamic_size=True)
  temp2 = tf.TensorArray(dtype=tf.float32, size=0, dynamic_size=True)
  temp1 = temp1.write(temp1.size(), tf.constant(1.))
  temp2 = temp2.write(temp2.size(), tf.constant(10.))
  cond=tf.convert_to_tensor([tf.constant(True),tf.constant(True),tf.constant(False),tf.constant(True),tf.constant(False)])
  
  def if_body(t1, t2):
      return t1, t2
  
  def else_body(t1, t2, i):
      m1 = tf.map_fn(lambda index: tf.cast(i, dtype=tf.float32)*tf.constant(2.), tf.range(t1.size()+tf.constant(1)), dtype=tf.float32)
      m2 = tf.map_fn(lambda index: tf.cast(i, dtype=tf.float32)*tf.constant(5.), tf.range(t2.size()+tf.constant(1)), dtype=tf.float32)
      ta1 = tf.TensorArray(dtype=tf.float32, size=0, dynamic_size=True)
      ta2 = tf.TensorArray(dtype=tf.float32, size=0, dynamic_size=True)
      t1 = ta1.unstack(m1)
      t2 = ta2.unstack(m2)
      # 1st return with t1 = [4.,4.], t2 = [10.,10.], i = 2.
      # end return with t1 = [8.,8.,8.], t2 = [20.,20., 20.], i = 4.
      return t1, t2 
  
  def loop_body(i, t1, t2, cond):
      t1, t2 = tf.cond(cond[i], # for i = 2 and i = 4 condition is False 
              lambda: if_body(t1, t2),
              lambda: else_body(t1, t2, i) #1st call with else_body([1.],[10.],2), 2nd call with else_body([4.,4.],[10.,10.],4)
              )
      i = tf.add(i, tf.constant(1))
      return i, t1, t2, cond
  
  _, temp1, temp2, _ = tf.while_loop(lambda i, temp1, temp2, cond:tf.less(i, tf.constant(5)), loop_body, [tf.constant(0), temp1, temp2, cond])
  
  # Expected output
  # temp1 = [8. 8. 8.]
  # temp2 = [20. 20. 20.]
  
  with tf.Session() as ss:
      print(ss.run([temp1.identity().stack(), temp2.identity().stack()]))
  </code></pre>
  
  <p>Here TensorArray temp1 and temp2 is not updating. If we modify directly t1 and t2 in else_body() its is getting reflected in temp1 and temp2. Replace else_body() with bellow code to semulate this.</p>
  
  <pre><code>def else_body(t1, t2, i):
      t1 = t1.write(t1.size(), tf.cast(i, dtype = tf.float32))
      t2 = t2.write(t2.size(), tf.cast(i, dtype = tf.float32))    
      return t1, t2 
  </code></pre>
  
  <p><strong>When we are creating a new TensorArray and returing it, still gatting value from initial TensorArray, not from new TensorArray.</strong> </p>