title: Batch normalization update with boolean tensor
body: <p>I know that using batch normalization in Tensorflow is a solved problem, but I ran into something I don't quite understand while adopting the code available to my needs.</p>
  
  <p><strong>Problem</strong>: It seems that when working with conditional branches the order you put the branches inside the cond() function matters.</p>
  
  <p>I put together the following minimal example:</p>
  
  <pre><code>import tensorflow as tf
  
  inpt = tf.placeholder(tf.float32, shape=[1])
  do_update = tf.placeholder(tf.bool)
  
  ema = tf.train.ExponentialMovingAverage(0.5)
  
  def update():
      ema_assign = ema.apply([inpt])
      with tf.control_dependencies([ema_assign]):
          return tf.identity(ema.average(inpt))
  
  def no_update():
      return ema.average(inpt)
  
  run = tf.python.control_flow_ops.cond(do_update, update, no_update) # this works
  # run = tf.python.control_flow_ops.cond(do_update, no_update, update) # this doesn't work
  # run = tf.python.control_flow_ops.cond(tf.logical_not(do_update), no_update, update) # this doesn't work as well
  
  sess = tf.Session()
  init = tf.initialize_all_variables()
  sess.run(init)
  
  for _ in range(10):
      run_v = sess.run([run], feed_dict={do_update: True, inpt: [1.0]})
      print run_v[0]
  
  run_v = sess.run([run], feed_dict={do_update: False, inpt: [1000.0]})
  print run_v[0]
  </code></pre>
  
  <p>The first line <em>run = ...</em> is not a problem to tensorflow and for me that outputs (as expected):</p>
  
  <pre><code>[ 0.5]
  [ 0.75]
  [ 0.875]
  [ 0.9375]
  [ 0.96875]
  [ 0.984375]
  [ 0.9921875]
  [ 0.99609375]
  [ 0.99804688]
  [ 0.99902344]
  [ 0.99902344]
  </code></pre>
  
  <p>However, for the second and third line I get a ValueError:</p>
  
  <pre><code>ValueError: fn1 and fn2 must return the same number of results.
  </code></pre>
  
  <p>It seems like it's important that the fn1 branch is the one containing the Average update, but I have no clue why that makes sense. Any thoughts about that behavior?</p>