title: Tensorflow: Random selection of masks
body: <p>I know that <a href="https://stackoverflow.com/questions/34959853/how-to-make-an-if-statement-using-a-boolean-tensor">this stackoverflow thread</a> already gives some nice examples about conditionals in tensorflow, but I'm still struggling how to solve my issue of randomly selecting among several different masks in tensorflow.<br>
  Right now I can only select between two mask tensors <code>a</code> and <code>b</code>:  </p>
  
  <pre><code>rand_num = tf.random_uniform([], minval=0, maxval=2.0, dtype=tf.float32, seed=None)
  def if_true():
       return b
  def if_false():
       return a
  mask_sel = tf.cond(tf.less(rand_num , tf.constant(1.0)),if_true,if_false)
  </code></pre>
  
  <p>(I still find it weird that one needs to define these two helper functions, but not using them weirdly throws an error.)<br>
  Now the question: Lets say I have 4 mask tensors (a,b,c,d) or more to randomly select, what would be the best way to do that in tensorflow?  </p>
  
  <p>In python that would be  </p>
  
  <pre><code>rand_num = np.random.uniform(low=0,high=4.0)
  if (rand_num &lt; 1.0):
      mask_sel = a
  elif(rand_num &lt; 2.0):
      mask_sel = b
  elif(rand_num &lt; 3.0):
      mask_sel = c
  else
      mask_sel = d
  </code></pre>