title: Creating a torch tensor from a generator
body: <p>I attempt to construct a tensor from a generator as follows:</p>
  
  <pre><code>&gt;&gt;&gt; torch.tensor(i**2 for i in range(10))
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  RuntimeError: Could not infer dtype of generator
  </code></pre>
  
  <p>Currently I just do:</p>
  
  <pre><code>&gt;&gt;&gt; torch.tensor([i**2 for i in range(10)])
  tensor([ 0,  1,  4,  9, 16, 25, 36, 49, 64, 81])
  </code></pre>
  
  <p>Is there a way to avoid needing this intermediate list?</p>