You could add a condition using the internal self.training argument:
        out = torch.reshape(out,(512,256,8,8))
        # to here,  I don't want it to perform at evaluation
        if self.training: # will only be called during training
            out = self.layer4(out)

The self.training argument is set to True or False by calling model.train() and model.eval(), respectively.