I think it can help:
class CustomResNet(nn.Module):
    def __init__(self, model):
        super(CustomResNet, self).__init__()
        self.model = model
        self.part = nn.Sequential(
            model.conv1,
            model.bn1,
            model.relu,
            model.maxpool,
            model.layer1,
            model.layer2,
            model.layer3
        )
    def forward(self, x):
        x = self.part(x)
        return x

model = torchvision.models.resnet18(pretrained=True)
x = torch.randn(1, 3, 224, 224)
my_model = CustomResNet(model=model)
my_model(x).shape

But if you see the fine tuning section 17 of  transfer learning tutorial, you can see that fc is a specific layer in resnet18 which can be accessed simply by model.fc. You might ask what about other layers, in the first post I have mentioned that:



 Nikronic:

If you want to get the model’s architecture, just use print(model)


So, by printing this, you will find that resnet has been constructed using the layers I have used in the snippet in this post.
PyTorch is highly modular framework, that is why we need to read the docs thoroughly.
Bests