I guess you might be using different PyTorch versions in your IDE and Jupyter, where apparently some operations might yield different shapes.
Could you check the versions via print(torch.__version__) and make sure they are equal?