| 1515 | ) |
| 1516 | class BertForSequenceClassification(BertPreTrainedModel): |
| 1517 | def __init__(self, config): |
| 1518 | super().__init__(config) |
| 1519 | self.num_labels = config.num_labels |
| 1520 | self.config = config |
| 1521 | |
| 1522 | self.bert = BertModel(config) |
| 1523 | classifier_dropout = ( |
| 1524 | config.classifier_dropout if config.classifier_dropout is not None else config.hidden_dropout_prob |
| 1525 | ) |
| 1526 | self.dropout = nn.Dropout(classifier_dropout) |
| 1527 | self.classifier = nn.Linear(config.hidden_size, config.num_labels) |
| 1528 | |
| 1529 | # Initialize weights and apply final processing |
| 1530 | self.post_init() |
| 1531 | |
| 1532 | @add_start_docstrings_to_model_forward(BERT_INPUTS_DOCSTRING.format("batch_size, sequence_length")) |
| 1533 | @add_code_sample_docstrings( |