How to use SegFormer encoder and decoder?

I am looking into SegFormer model, and I am able to fine tune it SegformerForSemanticSegmentation. Now I want to split the model into encoder-decoder and use them separately for my task, how can I use encoder or decoder part of the model?

As shown here, you can access them using the segformer and decode_head attributes respectively.

Thank you for sharing this link, I see SegformerDecodeHead rely on num_encoder_blocks and encoder_hidden_state; most likely this and other parameters would be defined in config.

Is there a documentation on how to use encoder and decoders or how this model was implemented or code walk-through? Maybe a documentation or sample code from another model usage might also help.