Repository: pytorch
Issue: Torchvision error TypeError: _resolve_type_from_object()
Labels: triaged,module: vision

## 🐛 Bug

<!-- A clear and concise description of what the bug is. -->

## To Reproduce

Steps to reproduce the behavior:

1.import torchvision
2.print(torchvision.__version__)


> --------------------------------------------------------------------------- TypeError Traceback (most recent call last) in ----> 1 import torchvision 2 print(torchvision.version)
> 
> ~/.local/lib/python3.5/site-packages/torchvision/init.py in 1 import warnings 2 ----> 3 from torchvision import models 4 from torchvision import datasets 5 from torchvision import ops
> 
> ~/.local/lib/python3.5/site-packages/torchvision/models/init.py in 10 from .shufflenetv2 import * 11 from . import segmentation ---> 12 from . import detection 13 from . import video 14 from . import quantization
> 
> ~/.local/lib/python3.5/site-packages/torchvision/models/detection/init.py in ----> 1 from .faster_rcnn import * 2 from .mask_rcnn import * 3 from .keypoint_rcnn import *
> 
> ~/.local/lib/python3.5/site-packages/torchvision/models/detection/faster_rcnn.py in 12 from .generalized_rcnn import GeneralizedRCNN 13 from .rpn import AnchorGenerator, RPNHead, RegionProposalNetwork ---> 14 from .roi_heads import RoIHeads 15 from .transform import GeneralizedRCNNTransform 16 from .backbone_utils import resnet_fpn_backbone
> 
> ~/.local/lib/python3.5/site-packages/torchvision/models/detection/roi_heads.py in 208 209 --> 210 @torch.jit.script 211 def _onnx_heatmaps_to_keypoints_loop(maps, rois, widths_ceil, heights_ceil, 212 widths, heights, offset_x, offset_y, num_keypoints):
> 
> ~/.local/lib/python3.5/site-packages/torch/jit/init.py in script(obj, optimize, _frames_up, _rcb) 1288 if _rcb is None: 1289 _rcb = _jit_internal.createResolutionCallbackFromClosure(obj) -> 1290 fn = torch._C._jit_script_compile(qualified_name, ast, _rcb, get_default_args(obj)) 1291 # Forward docstrings 1292 fn.doc = obj.doc
> 
> ~/.local/lib/python3.5/site-packages/torch/jit/_recursive.py in try_compile_fn(fn, loc) 566 # object 567 rcb = _jit_internal.createResolutionCallbackFromClosure(fn) --> 568 return torch.jit.script(fn, _rcb=rcb) 569 570 def wrap_cpp_module(cpp_module):
> 
> ~/.local/lib/python3.5/site-packages/torch/jit/init.py in script(obj, optimize, _frames_up, _rcb) 1288 if _rcb is None: 1289 _rcb = _jit_internal.createResolutionCallbackFromClosure(obj) -> 1290 fn = torch._C._jit_script_compile(qualified_name, ast, _rcb, get_default_args(obj)) 1291 # Forward docstrings 1292 fn.doc = obj.doc
> 
> ~/.local/lib/python3.5/site-packages/torch/jit/init.py in _get_overloads(obj) 2028 compiled_fns = [] 2029 for overload_fn in uncompiled_overloads: -> 2030 compiled_fns.append(_compile_function_with_overload(overload_fn, qual_name, obj)) 2031 2032 if existing_compiled_fns:
> 
> ~/.local/lib/python3.5/site-packages/torch/jit/init.py in _compile_function_with_overload(overload_fn, qual_name, impl_fn) 2008 def _compile_function_with_overload(overload_fn, qual_name, impl_fn): 2009 overload_decl = torch.jit.get_jit_def(overload_fn).decl() -> 2010 overload_signature = torch.jit.annotations.get_signature(overload_fn, None, None, inspect.ismethod(overload_fn)) 2011 impl_ast = torch.jit.get_jit_def(impl_fn) 2012 overload_defaults = get_default_args(overload_fn)
> 
> ~/.local/lib/python3.5/site-packages/torch/jit/annotations.py in get_signature(fn, rcb, loc, is_method) 77 # because it didn't have any annotations. 78 if type_line is not None: ---> 79 signature = parse_type_line(type_line, rcb, loc) 80 81 return signature
> 
> ~/.local/lib/python3.5/site-packages/torch/jit/annotations.py in parse_type_line(type_line, rcb, loc) 163 raise RuntimeError("Failed to parse the return type of a type annotation: {}".format(str(e))) 164 --> 165 arg_types = [ann_to_type(ann, loc) for ann in arg_ann] 166 return arg_types, ann_to_type(ret_ann, loc) 167
> 
> ~/.local/lib/python3.5/site-packages/torch/jit/annotations.py in (.0) 163 raise RuntimeError("Failed to parse the return type of a type annotation: {}".format(str(e))) 164 --> 165 arg_types = [ann_to_type(ann, loc) for ann in arg_ann] 166 return arg_types, ann_to_type(ret_ann, loc) 167
> 
> ~/.local/lib/python3.5/site-packages/torch/jit/annotations.py in ann_to_type(ann, loc) 301 302 def ann_to_type(ann, loc): --> 303 the_type = try_ann_to_type(ann, loc) 304 if the_type is not None: 305 return the_type
> 
> ~/.local/lib/python3.5/site-packages/torch/jit/annotations.py in try_ann_to_type(ann, loc) 294 def fake_rcb(key): 295 return None --> 296 the_type = torch._C._resolve_type_from_object(ann, loc, fake_rcb) 297 if the_type is not None: 298 return the_type
> 
> TypeError: _resolve_type_from_object(): incompatible function arguments. The following argument types are supported: 1. (arg0: object, arg1: torch._C._jit_tree_views.SourceRange, arg2: Callable[[str], function]) -> torch._C.Type
> 
> Invoked with: typing.Union[int, NoneType], None, .fake_rcb at 0x7f55d8974ea0>

## Expected behavior

<!-- A clear and concise description of what you expected to happen. -->
Print the version of Torchvision
## Environment

Please copy and paste the output from our
[environment collection script](https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py)
(or fill out the checklist below manually).

You can get the script and run it with:
```
wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
```
Collecting environment information...
PyTorch version: 1.5.0
Is debug build: No
CUDA used to build PyTorch: 10.1

OS: Ubuntu 16.04.6 LTS
GCC version: (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609
CMake version: version 3.5.1

Python version: 3.7
Is CUDA available: Yes
CUDA runtime version: Could not collect
GPU models and configuration: 
GPU 0: TITAN X (Pascal)
GPU 1: TITAN X (Pascal)
GPU 2: TITAN X (Pascal)

Nvidia driver version: 418.87.01
cuDNN version: /usr/lib/x86_64-linux-gnu/libcudnn.so.7.6.5

Versions of relevant libraries:
[pip3] numpy==1.16.2
[pip3] torch==1.5.0+cu101
[pip3] torchvision==0.6.0+cu101
[conda] blas                      1.0                         mkl  
[conda] cudatoolkit               10.1.243             h6bb024c_0  
[conda] mkl                       2020.1                      217  
[conda] mkl-service               2.3.0            py37he904b0f_0  
[conda] mkl_fft                   1.0.15           py37ha843d7b_0  
[conda] mkl_random                1.1.0            py37hd6b4f25_0  
[conda] numpy                     1.18.1           py37h4f9e942_0  
[conda] numpy-base                1.18.1           py37hde5b4d6_1  
[conda] pytorch                   1.5.0           py3.7_cuda10.1.243_cudnn7.6.3_0    pytorch
[conda] torchvision               0.6.0                py37_cu101    pytorch


cc @fmassa