If you’re loading a pretrained model that has been finetuned for a classification task, you can look at the value in its config file with:
from transformers import AutoConfig
config = AutoConfig.from_pretrained('checkpoint_name')
config.num_labels