How to add extra dense layer on top of BertForSequenceClassification?
I want to add an extra layer (and dropout) before the classification layer (I'm using PyTorch lightning) What is the best way to do it?

The class BertForSequenceClassification (that comes from the Huggingface Transformers when using PyTorch lightning) implements a fixed architecture. If you want to change it (e.g., by adding layers), you need to inherit your own module.
This is actually quite simple. You can copy the code of BertForSequenceClassification and modify the code between getting the pooled BERT output and getting the logits.
Note however that adding a hidden layer to a classifier does not make much difference when finetuning BERT. The capacity of the additional hidden layer is negligible compared to the entire stack of BERT layers. Even If you cannot finetune the entire model, fine-tuning just the last BERT layer is probably better than adding an extra layer to the classifier.
