title: How do I do masking in PyTorch / Numpy with different dimensions?
body: <p>I have a <code>mask</code> with a size of <code>torch.Size([20, 1, 199])</code> and a tensor, <code>reconstruct_output</code> and <code>inputs</code> both with a size of <code>torch.Size([20, 1, 161, 199])</code>.</p>
  
  <p>I want to set <code>reconstruct_output</code> to <code>inputs</code> where the <code>mask</code> is <code>0</code>. I tried:</p>
  
  <pre><code>reconstruct_output[mask == 0] = inputs[mask == 0]
  </code></pre>
  
  <p>But I get an error:</p>
  
  <pre><code>IndexError: The shape of the mask [20, 1, 199] at index 2 does not match the shape of the indexed tensor [20, 1, 161, 199] at index 2
  </code></pre>