I’d go right before that line x += identity and print the shapes.
Clearly, only one of them can be the shape you expect.
You could also do the same to a working 2d resnet of the same structure and compare.
Best regards
Thomas