In the first example your definition of net1 is missing.
It could probably look like this:
class Net1(nn.Module):
    def __init__(self):
        super(Net1, self).__init__()
        self.net = nn.Linear(5, 5)
        self.fc = nn.Linear(5, 10)

    def forward(self, x):
        x = self.net(x)
        x = self.fc(x)
        return x

If this is the case, both models will work just fine.
Your first example looks more like a pre-trained model, where you would like to change the last linear layer to match your number of classes.
The second example is just a vanilla model.
As a small side note: you are missing the non-linearities. In PyTorch the layers do not include any activation functions, so that you would have to add them to your models.