PrintLayer doesn’t change the tensor shapes, but changes the model architecture, i.e. in an nn.Sequential block the number of modules is different and thus you would run into this error.
You could use forward hooks to print the shape in this use case if you want to load a pretrained state_dict.