Can not use x=torch.tensor(b), to create a Tensor out of a List[List[Tensor]] (A List of Lists of Tensors)

username: a.h.23
cooked: <p>Minimal Sample:</p>
<pre><code class="lang-auto">import torch
from typing import List

@torch.jit.script
def get_boxes(batch_bboxes=None):
    s = torch.jit.annotate(List[List[torch.Tensor]], [])
    s.append([torch.tensor(3.14)])
    s.append([torch.tensor(42.23)])
    bb = torch.tensor(s)
    print(bb)

get_boxes()
</code></pre>
<p>RuntimeError: The following operation failed in the TorchScript interpreter.<br>
Traceback of TorchScript (most recent call last):<br>
bb = torch.tensor(b)</p>
<pre><code class="lang-auto">RuntimeError: Input must be of ints, floats, or bools, got Tensor</code></pre>

username: AlphaBetaGamma96
cooked: <p>Hi <a class="mention" href="/u/a.h.23">@a.h.23</a>,</p>
<p>Have you tried using <code>torch.stack</code> to convert the List of Tensors to Tensor, then repeat again for the 2nd list?</p>

username: a.h.23
cooked: <p>Thx AlphaBetaGamma96 !</p>
<p>My solution was now this:</p>
<pre><code class="lang-auto">ccc= torch.empty((0,1))

for bbox in pb:
   ch = torch.stack([category], dim=0)
   ch = torch.unsqueeze(ch, 0)
   ccc = torch.cat((ccc, ch))
</code></pre>
<p>I also opend a Issue at the pytorch repo:</p><aside class="onebox githubissue" data-onebox-src="https://github.com/pytorch/pytorch/issues/90000">
  <header class="source">

      <a href="https://github.com/pytorch/pytorch/issues/90000" target="_blank" rel="noopener nofollow ugc">github.com/pytorch/pytorch</a>
  </header>

  <article class="onebox-body">
    <div class="github-row">
  <div class="github-icon-container" title="Issue">
	  <svg width="60" height="60" class="github-icon" viewbox="0 0 14 16" aria-hidden="true"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg>
  </div>

  <div class="github-info-container">
    <h4>
      <a href="https://github.com/pytorch/pytorch/issues/90000" target="_blank" rel="noopener nofollow ugc">Can not use x=torch.tensor(b), to create a Tensor out of a List[List[Tensor]] (A List of Lists of Tensors)</a>
    </h4>

    <div class="github-info">
      <div class="date">
        opened <span class="discourse-local-date" data-format="ll" data-date="2022-12-01" data-time="09:59:20" data-timezone="UTC">09:59AM - 01 Dec 22 UTC</span>
      </div>


      <div class="user">
        <a href="https://github.com/telemetrieTP23" target="_blank" rel="noopener nofollow ugc">
          <img alt="telemetrieTP23" src="https://avatars.githubusercontent.com/u/30113762?v=4" class="onebox-avatar-inline" width="20" height="20">
          telemetrieTP23
        </a>
      </div>
    </div>

    <div class="labels">
        <span style="display:inline-block;margin-top:2px;background-color: #B8B8B8;padding: 2px;border-radius: 4px;color: #fff;margin-left: 3px;">
          oncall: jit
        </span>
        <span style="display:inline-block;margin-top:2px;background-color: #B8B8B8;padding: 2px;border-radius: 4px;color: #fff;margin-left: 3px;">
          triaged
        </span>
    </div>
  </div>
</div>

  <div class="github-row">
    <p class="github-body-container">### 🐛 Describe the bug

Can not use x=torch.tensor(b), to create a Tensor out <span class="show-more-container"><a href="" rel="noopener" class="show-more">…</a></span><span class="excerpt hidden">of a List[List[Tensor]] (A List of Lists of Tensors) in Torchscript

Minimal Sample:
``` python
@torch.jit.script_if_tracing
def get_boxes(batch_bboxes):
      s = torch.jit.annotate(List[List[Tensor]], [])
      s.append([torch.tensor(3.14)]
      s.append([torch.tensor(42.23)]
      bb = torch.tensor(s)
```
``` bash
RuntimeError: The following operation failed in the TorchScript interpreter.
Traceback of TorchScript (most recent call last):
bb = torch.tensor(b)
                 ~~~~~~~~~~~~ &lt;--- HERE
RuntimeError: Input must be of ints, floats, or bools, got Tensor
```

### Versions

OS: macOS 12.2.1 (x86_64)
GCC version: Could not collect
Clang version: 13.1.6 (clang-1316.0.21.2)
CMake version: version 3.21.3
Libc version: N/A

Python version: 3.8.10 (v3.8.10:3d8993a744, May  3 2021, 08:55:58)  [Clang 6.0 (clang-600.0.57)] (64-bit runtime)
Python platform: macOS-10.16-x86_64-i386-64bit
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] numpy==1.23.5
[pip3] torch==1.13.0
[pip3] torchvision==0.14.0
[conda] Could not collect


cc @EikanWang @jgong5 @wenzhe-nrv @sanchitintel</span></p>
  </div>

  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>