Best practice to create custom head

I’m thinking about creating a custom head on Roberta model.
Like adding RobertaForTopicChangeDetection on

First thing I come up with is copy source code by pip install -t
and copy RobertaForSequenceClassification and modify it.

But I don’t think this is the right way to create custom RobertaForNewThing.

Could you give me the best way to do this?
Or if there is doc for that, please give me the link?

Thanks in advance.