title: Convert list of tensors into tensor pytorch
body: <p>I have a list of embeddings. The list has <code>N</code> lists with <code>M</code> embedding (tensors) each.</p>
  <pre><code>list_embd = [[M embeddings], [M embeddings], ...]
  </code></pre>
  <p>(Each embedding is a <code>tensor with size (1,512)</code>)</p>
  <p>What I want to do is create a <code>tensor size (N, M)</code>, where each <code>&quot;cell&quot;</code> is one embedding.</p>
  <p>Tried this for numpy array.</p>
  <pre><code>array = np.zeros(n,m)
  
  for i in range(n):
      for j in range(m):
          array[i, j] = list_embd[i][j]
  </code></pre>
  <p>But still got errors.</p>
  <p>In pytorch tried to <code>concat</code> all M embeddings into one tensor size (1, M), and then concat all rows. But when I concat along dim 1 two of those M embeddings, I get a tensor shaped (1, 1028) instead (1, 2).</p>
  <pre><code>final = torch.tensor([])
      for i in range(n):
          interm = torch.tensor([])
          for j in range(m):
              interm = torch.cat((interm, list_embd[i][j]), 0)
          final = = torch.cat((final, interm), 1)
  </code></pre>
  <p>Any ideas or suggestions?
  I need a matrix with the embeddings in each cell.</p>