The huggingface transformers library has a class for it and they also show a GLUE example:
https://huggingface.co/transformers/model_doc/bert.html#transformers.BertForSequenceClassification 1.5k
and the examples/run_glue.py from their github repository.
Best regards
Thomas4