Repository: pytorch
Issue: A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 9792 (Background), pid 9674 (ample.testtorch)
Labels: oncall: mobile

### 🐛 Describe the bug

Hello. I'm running into a problem on d2go when I'm trying to retrain a model. The assembly of the pt model is successful, but when I run the model in my Android Studio, I get an error:
```
E/libc++abi: terminating with uncaught exception of type c10::Error: isTuple()INTERNAL ASSERT FAILED at "../../../../src/main/cpp/libtorch_include/arm64-v8a/ ATen/core/ivalue_inl.h":1306, please report a bug to PyTorch. Expected Tuple but got String
    Exception raised from toTuple at ../../../../src/main/cpp/libtorch_include/arm64-v8a/ATen/core/ivalue_inl.h:1306 (most recent call first):
    (no backtrace available)
A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 9792 (Background), pid 9674 (ample.testtorch)
```
A similar [question]( https://github.com/pytorch/pytorch/issues/79875) was asked here, but the solution was not found, and the campaign about this question was already forgotten, so I decided to remind about it again😄. I am willing to share any information to resolve this issue. I tried running a model that was trained on balloon_dataset but got a similar error.
I already got acquainted with the source code of `ivalue_inl.h`, and have not yet understood what line 1306 has to do with it, but I found the assert code on line [1924](https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/core/ivalue_inl.h#L1924) and [1928](https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/core/ivalue_inl.h#L1928).
I assume that this is either related to the cfg configuration file when we generate it and a string was passed to some field instead of a tuple, or it is related somehow to the wrapper itself. If I understood everything correctly, then the trained model in the notebook works well, but when the wrapper itself is created, then an error occurs in java on Android. That is the model:
module = PyTorchAndroid.loadModuleFromAsset(getAssets(), "d2go_test.pt");
is not available, i.e. an error occurs here.
Maybe it's because I didn't call patch_d2_meta_arch()? It's just that the pytorch night version for some reason does not contain this import function, or I didn't search well. I also tried different versions of cuda nightly build of pytorch - without success. 

Collected and trained the project in Google Collab. I used pip instead of conda. This is how I set up the dependencies:
```
!pip install 'git+https://github.com/facebookresearch/detectron2.git'
!pip install 'git+https://github.com/facebookresearch/d2go'
!pip install 'git+https://github.com/facebookresearch/mobile-vision.git'
!pip uninstall torch -y
!pip uninstall torchvision -y
!pip install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cu102   # Tried cu102 and cu116
```
Try installing the packages as well to reproduce the error. I also tried to create my own dataset with 1 class - car, and created the annotation file via_region_data.json through this [site](https://www.robots.ox.ac.uk/~vgg/software/via/via-1.0.6.html)

I took the code directly from d2go_beginner.ipynb. If you need a code - just try to train a model in d2go_beginner.ipynb ONLY for 1 class - balloon with `faster_rcnn_fbnetv3a_dsmask_C4.yaml` or `faster_rcnn_fbnetv3a_C4.yaml` from the example and tell me if this model works for you on android. Be careful, because in the instructions here it says:
```
def prepare_for_launch():
     runner = GeneralizedRCNNRunner()
     cfg = runner.get_default_cfg()
     cfg.merge_from_file(model_zoo.get_config_file("faster_rcnn_fbnetv3a_C4.yaml"))   <- written faster_rcnn_fbnetv3a_C4.yaml
     ...
```
And in the next cell it says:
```
import copy
from detectron2.data import build_detection_test_loader
from d2go.export.exporter import convert_and_export_predictor
from d2go.utils.testing.data_loader_helper import create_detection_data_loader_on_toy_dataset
# from d2go.export.d2_meta_arch import patch_d2_meta_arch   # i commented

import logging

# disable all the warnings
previous_level = logging.root.manager.disable
logging.disable(logging.INFO)

patch_d2_meta_arch()   # I could not find this import at all in any of the versions of pytorch, could this be the problem? I run model without this import.

cfg_name = 'faster_rcnn_fbnetv3a_dsmask_C4.yaml'   # <- written already faster_rcnn_fbnetv3a_dsmask_C4.yaml. Is it so necessary, or did you accidentally mix up the yaml files?
pytorch_model = model_zoo.get(cfg_name, trained=True, device='cpu')
...
```

Code of Wrapper:
```
from typing import List, Dict
import torch 

class Wrapper(torch.nn.Module):
  def __init__(self, model):
      super().__init__()
      self.model = model
      coco_idx_list = [1]
      
      self.coco_idx = torch.tensor(coco_idx_list)
  
  def forward(self, inputs: List[torch.Tensor]):
    x = inputs[0].unsqueeze(0) * 255
    scale = 320.0 / min(x.shape[-2], x.shape[-1])
    x = torch.nn.functional.interpolate(x, scale_factor=scale, mode='bilinear', align_corners=True, recompute_scale_factor=True)
    out = self.model(x[0])
    res: Dict[str, torch.Tensor] = {}
    res["boxes"] = out[0] /scale 
    res["labels"] = torch.index_select(self.coco_idx, 0, out[1])
    res["scores"] = out[2]
    return inputs, [res]

orig_model = torch.jit.load(os.path.join(predictor_path, "model.jit"))
wrapped_model = Wrapper(orig_model)
scripted_model = torch.jit.script(wrapped_model)
scripted_model.save("/content/d2go_test.pt")
```
Ask any questions - I will answer what I can. 
P.S. Sorry for my English:)




### Versions

Collecting environment information...
PyTorch version: 1.13.0.dev20220726+cu102
Is debug build: False
CUDA used to build PyTorch: 10.2
ROCM used to build PyTorch: N/A

OS: Ubuntu 18.04.5 LTS (x86_64)
GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Clang version: 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
CMake version: version 3.22.5
Libc version: glibc-2.26

Python version: 3.7.13 (default, Apr 24 2022, 01:04:09)  [GCC 7.5.0] (64-bit runtime)
Python platform: Linux-5.4.188+-x86_64-with-Ubuntu-18.04-bionic
Is CUDA available: True
CUDA runtime version: 11.1.105
GPU models and configuration: GPU 0: Tesla T4
Nvidia driver version: 460.32.03
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.7.6.5
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.0.5
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.21.6
[pip3] pytorch-lightning==1.6.0.dev0
[pip3] torch==1.13.0.dev20220726+cu102
[pip3] torchaudio==0.13.0.dev20220726+cu102
[pip3] torchmetrics==0.9.3
[pip3] torchsummary==1.5.1
[pip3] torchtext==0.13.0
[pip3] torchvision==0.14.0.dev20220726+cu102
[conda] Could not collect