def exception_hook(exc_type, exc_value, tb):
r'''Hacks the call stack message in case of RuntimeError to show all
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.
+ the local variables, and indicate for every tensor involved its
+ shape, dtype and device.
filename = tb.tb_frame.f_code.co_filename
name = tb.tb_frame.f_code.co_name
line_no = tb.tb_lineno
print(f' File "{filename}", line {line_no}, in {name}')
filename = tb.tb_frame.f_code.co_filename
name = tb.tb_frame.f_code.co_name
line_no = tb.tb_lineno
print(f' File "{filename}", line {line_no}, in {name}')