title: How does PyTorch Tensor.index_select() evaluates tensor output?
body: <p>I am not able to understand how complex indexing - non contiguous indexing of a tensor works. Here is a sample code and its output</p>
  <pre><code>import torch
  
  def describe(x):
    print(&quot;Type: {}&quot;.format(x.type()))
    print(&quot;Shape/size: {}&quot;.format(x.shape))
    print(&quot;Values: \n{}&quot;.format(x))
  
  
  indices = torch.LongTensor([0,2])
  x = torch.arange(6).view(2,3)
  describe(torch.index_select(x, dim=1, index=indices))
  </code></pre>
  <p>Returns output as</p>
  <blockquote>
  <p>Type: torch.LongTensor Shape/size: torch.Size([2, 2]) Values:
  tensor([[0, 2],
  [3, 5]])</p>
  </blockquote>
  <p>Can someone explain how did it arrive to this output tensor?
  Thanks!</p>