def METHOD_NAME(self, model, sample, reduce=True):
    """Compute the loss for the given sample.
    Returns a tuple with three elements:
    1) the loss
    2) the sample size, which is used as the denominator for the gradient
    3) logging outputs to display while training
    """
    net_output = model(**sample["net_input"])
    loss, num_corr, num_tot, state_post = self.compute_loss(
        model, net_output, sample, reduce=reduce
    )
    sample_size = (
        sample["target"].size(0) if self.sentence_avg else sample["ntokens"]
    )
    logging_output = {
        "loss": loss.data,
        "ntokens": sample["ntokens"],
        "nsentences": sample["target"].size(0),
        "sample_size": sample_size,
        "num_corr": num_corr,
        "num_tot": num_tot,
        "state_post": state_post,
    }
    return loss, sample_size, logging_output