You could change the forward method and return the hidden layer output additionally to or instead of the original output.
If your desired hidden layer is quite at the front of the model, it’s sometimes easier to “call” each modules:
hidden = model.layer2(F.relu(model.layer1(data)))

But this will get quite ugly if it’s not a layer at the front of your model.