title: return the top_k masked softmax of each row for a 2D tensor
body: <p>For any 2D tensor like </p>
  
  <p>[[2,5,4,7],
  [7,5,6,8]], </p>
  
  <p>I want to do softmax for the top <em>k</em> element in each row and then construct a new tensor by replacing all the other elements to 0.</p>
  
  <p>The result should be to get the softmax of top <em>k</em> (here k=2) elements for each row [[7,5],[8,7]], 
  which is thus
  [[0.880797,0.11920291],
  [0.7310586,0.26894143]] 
  and then reconstruct a new tensor according to the index of the top <em>k</em> elements in the original tensor, the final result should be </p>
  
  <p>[[0,0.11920291,0,0.880797],
  [0.26894143,0,0,0.7310586]].</p>
  
  <p>Is it possible to implement this kind of <em>masked softmax</em> in tensorflow? Many thanks in advance!</p>