How to fine tune BERT with customized classifier and loss function?

I would like to fine tune BERT on my own data and task, is there an easy way to add my own classifier and loss function based on the trainer module?