Say you have defined a model that follows the same structure as densenet121 till the transition2. Now you want to load the original weights of densenet in your new model. Every layer in your model will have a name and corresponding weights. All the weights of your model are stored as a dictionary, where the key is the layer name and value is the weights of that layer.
To get a part of the model, you can thus only select those (key, value) pairs that you want which in your case are till transition2.