How to separate an encoder of a vision unet

Hello everyone!
I am working on a project in which I am having to make an unet, which generates pictures from pictures and after that, I want to separate the encoder of that vision encoder and want to have the last tensor of the unet’s encoder as an output of the net.
But I don’t know how to separate the encoder from the vision unet.
Any help will be appreciated.
Thanks!!