title: In Torch how do I create a 1-hot tensor from a list of integer labels?
body: <p>I have a byte tensor of integer class labels, e.g. from the MNIST data set.</p>
  
  <pre><code> 1
   7
   5
  [torch.ByteTensor of size 3]
  </code></pre>
  
  <p>How do use it to create a tensor of 1-hot vectors?</p>
  
  <pre><code> 1  0  0  0  0  0  0  0  0  0
   0  0  0  0  0  0  1  0  0  0
   0  0  0  0  1  0  0  0  0  0
  [torch.DoubleTensor of size 3x10]
  </code></pre>
  
  <p>I know I could do this with a loop, but I'm wondering if there's any clever Torch indexing that will get it for me in a single line.</p>