It depends on the model.
If you are slicing a nn.Sequential model, you can just keep your desired layers and wrap them in a new nn.Sequential instance:
model = nn.Sequential(
    nn.Linear(10, 10),
    nn.ReLU(),
    nn.Linear(10, 10),
    nn.ReLU(),
    nn.Linear(10, 10),
    nn.ReLU(),
    nn.Linear(10, 10),
    nn.ReLU(),
)

model = nn.Sequential(*list(model.children())[:2])

x = torch.randn(1, 10)
output = model(x)

In case of a custom model with an own forward, you would need to rewrite this method.