A easier way to transfer your learning is simply to load you model state dict and then modify the last layer instead of creating a new class.
do torch.save(model.state_dict(), "model_a.pth’) once the Model_TL_A has finished learning.
Then when you want to start training your model_B:
model_B = Model_TL_A()
model_B.load_state_dict(torch.load(“model_a.pth”))
model.linear1 = nn.Linear(in_features=784, out_features=number_of_outputs)
Of course there are variants, but this is most simple way to go in my opinion.