Import torchvision error - TypeError: _resolve_type_from_object(): incompatible function arguments

Hi, I am trying to run the following import instructions in a jupyter notebook but torchvision is giving me a problem

from __future__ import print_function, division 
! python --version 
! python2 --version 
! python3 --version 
import os 
import torch 
import pandas as pd 
from skimage import io, transform 
import numpy as np 
import matplotlib.pyplot as plt 
from torch.utils.data import Dataset, DataLoader 
import sys 
print(sys.version) 
import torchvision
# from torchvision import transforms, utils

The output is the following

Python 3.5.2
Python 2.7.12
Python 3.5.2
3.5.2 (default, Apr 16 2020, 17:47:17) 
[GCC 5.4.0 20160609]
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-3a8a37d1acbb> in <module>
     12 import sys
     13 print(sys.version)
---> 14 import torchvision
     15 # from torchvision import transforms, utils

~/virtualenvs/testenv1/lib/python3.5/site-packages/torchvision/__init__.py in <module>
      1 import warnings
      2 
----> 3 from torchvision import models
      4 from torchvision import datasets
      5 from torchvision import ops

~/virtualenvs/testenv1/lib/python3.5/site-packages/torchvision/models/__init__.py in <module>
     10 from .shufflenetv2 import *
     11 from . import segmentation
---> 12 from . import detection
     13 from . import video
     14 from . import quantization

~/virtualenvs/testenv1/lib/python3.5/site-packages/torchvision/models/detection/__init__.py in <module>
----> 1 from .faster_rcnn import *
      2 from .mask_rcnn import *
      3 from .keypoint_rcnn import *

~/virtualenvs/testenv1/lib/python3.5/site-packages/torchvision/models/detection/faster_rcnn.py in <module>
     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

~/virtualenvs/testenv1/lib/python3.5/site-packages/torchvision/models/detection/roi_heads.py in <module>
    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):

~/virtualenvs/testenv1/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__

~/virtualenvs/testenv1/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):

~/virtualenvs/testenv1/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__

~/virtualenvs/testenv1/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:

~/virtualenvs/testenv1/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)

~/virtualenvs/testenv1/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

~/virtualenvs/testenv1/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 

~/virtualenvs/testenv1/lib/python3.5/site-packages/torch/jit/annotations.py in <listcomp>(.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 

~/virtualenvs/testenv1/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

~/virtualenvs/testenv1/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, <function try_ann_to_type.<locals>.fake_rcb at 0x7f8aa1ad2e18>

I tried to search on the internet but I could not find anything. Any ideas on how to solve this problem?

Thanks!

I actually found only now this issue that seems exactly the same one I am facing: