def METHOD_NAME(
    self,
    input_ids=None,
    attention_mask=None,
    langs=None,
    token_type_ids=None,
    position_ids=None,
    lengths=None,
    cache=None,
    head_mask=None,
    inputs_embeds=None,
    labels=None,
):
    transformer_outputs = self.transformer(
        input_ids,
        attention_mask=attention_mask,
        langs=langs,
        token_type_ids=token_type_ids,
        position_ids=position_ids,
        lengths=lengths,
        cache=cache,
        head_mask=head_mask,
    )
    output = transformer_outputs[0]
    logits = self.sequence_summary(output)
    outputs = (logits,) + transformer_outputs[
        1:
    ]  # Keep new_mems and attention/hidden states if they are here
    if labels is not None:
        if self.num_labels == 1:
            #  We are doing regression
            loss_fct = MSELoss()
            loss = loss_fct(logits.view(-1), labels.view(-1))
        else:
            if self.weight is not None:
                weight = self.weight.to(labels.device)
            else:
                weight = None
            loss_fct = CrossEntropyLoss(weight=weight)
            loss = loss_fct(logits.view(-1, self.num_labels), labels.view(-1))
        outputs = (loss,) + outputs
    return outputs