You can define a model with only the first 12 layers, then load the state_dict into it with strict=false. That should work (assuming the layers have the original names). Otherwise you could iterate over the model parameters like so:
for name, param in model.named_parameters():
    ... do something with each parameter

I think the first version is better.