How to get the output of an intermediate layer of a network

How to get the output of an intermediate layer of a network

There are multiple ways, e.g. registering a forward hook, activating first part + save results + activate second part.