| 587 | """ |
| 588 | |
| 589 | def __init__(self, config): |
| 590 | super().__init__(config) |
| 591 | self.num_labels = config.num_labels |
| 592 | self.config = config |
| 593 | |
| 594 | self.bert = BertModel(config) |
| 595 | classifier_dropout = ( |
| 596 | config.classifier_dropout if config.classifier_dropout is not None else config.hidden_dropout_prob |
| 597 | ) |
| 598 | self.dropout = nn.Dropout(classifier_dropout) |
| 599 | |
| 600 | # In multiple choice tasks, all choices are submitted in a batch, and |
| 601 | # we compute a logit for each option independently. The logits are then |
| 602 | # normalized in the forward pass to get a probability distribution over |
| 603 | # the choices. |
| 604 | self.classifier = nn.Linear(config.hidden_size, 1) |
| 605 | |
| 606 | # Initialize weights and apply final processing |
| 607 | self.post_init() |
| 608 | |
| 609 | @classmethod |
| 610 | def from_composer( |