title: How to select indices according to another tensor in pytorch?
body: <p>I have two tensors a and b. And I want to retrive the values of b according to the positions of max values in a. That is,</p>
  <p>max_values, indices = torch.max(a, dim=0, keepdim=True)</p>
  <p>However, I do not know how to use the indices to retrive the values of b. Can anybody helps to solve it? Thanks a lot!!</p>
  <p>Edit:</p>
  <p>Sorry for not describing my problem concretely. To give a minimal example, the value of tensors a and b are:</p>
  <pre><code>    a = torch.tensor([[1,2,4],[2,1,3]])
      b = torch.tensor([[10,24,2],[23,4,5]])
  </code></pre>
  <p>If I use <code>torch.max(a, dim=0, keepdim=True)</code>, it will return:</p>
  <pre><code>    max:  tensor([[2, 2, 4]])
      indices:   tensor([[1, 0, 0]])
  </code></pre>
  <p>What I want to obtain is the selected value of tensor b according to the indices of max values of a in <code>dim=0</code>, that is,</p>
  <pre><code>    tensor([[23, 24, 2]])
  </code></pre>
  <p>I have tried <code>b[indices]</code>, whereas the result is not what I want:</p>
  <pre><code>    tensor([[[ 2,  3,  5],
               [10, 30, 40],
               [10, 30, 40]]])
  </code></pre>