Could you check, if the parameters of the frozen layers get valid gradients after the backward call via:
loss.backward()
print(self.model.frozen_layer.weight.grad)
print(self.model.last_layer.weight.grad)

If the frozen layers yield None, while the last linear layer yields a valid gradient, your code is working as expected.