import sys
def exception_hook(exc_type, exc_value, tb):
+ r'''Hacks the call stack message in case of RuntimeError to show all
+ the local variables, and indicate for every tensor its shape,
+ dtype and device.
+
+ '''
repr_orig=Tensor.__repr__
Tensor.__repr__=lambda x: f'{x.size()}:{x.dtype}:{x.device}'