You can simply assign the last layer manually after loading it.
e.g.,
pretrained_model = [some steps that gave me the pretrained model]
pretrained_model.fc = nn.Linear(input_channels, num_classes)

should work for most pretrained models in torchvision.