title: Get masked argmax with different mask for each row in TensorFlow
body: <p>I have a tensor of shape Nx7, which looks something like this:</p>
  
  <pre><code>[0.97863993   0.64479575 -0.202357    0.94678476  0.0080051   0.44507797 0.47864
   0.05914348  -0.72649432  0.193803    0.47295245  0.8381458   0.30449861 0.46783]
  </code></pre>
  
  <p>I have another tensor of the same shape, which is a boolean mask:</p>
  
  <pre><code>[True  False True  True  False True  False
   False True  False False True  False False]
  </code></pre>
  
  <p>I want to get the argmax of each row in the first tensor, but only of those elements for which the mask is True, so basically the argmax of the following array:</p>
  
  <pre><code>[0.97863993  X          -0.202357    0.94678476  X           0.44507797 X
   X          -0.72649432  X           X           0.8381458   X          X]
  </code></pre>
  
  <p>Which should thus become:</p>
  
  <pre><code>[0
   4]
  </code></pre>
  
  <p>Is this possible in TensorFlow? I am trying to figure it out with <code>tf.boolean_mask</code>, but I don't see how to deal with different rows having differing numbers of <code>True</code> values in the mask.</p>
  
  <p>Input code in TF:</p>
  
  <pre><code>mask = tf.placeholder(shape=[None, 7], dtype=tf.bool)
  val = tf.placeholder(shape=[None, 7], dtype=tf.float32)
  
  arg_max = ???
  </code></pre>
  
  <p>Note that I want negative values to be handled correctly as well (otherwise the method proposed by Ishant Mrinal would work).</p>