def METHOD_NAME(self, sample, target, lprobs, loss):
    target = target.view(-1)
    mask = target != self.padding_idx
    correct = torch.sum(
        lprobs.argmax(1).masked_select(mask) == target.masked_select(mask)
    )
    total = torch.sum(mask)
    sample_size = (
        sample["target"].size(0) if self.sentence_avg else sample["ntokens"]
    )
    logging_output = {
        "loss": utils.item(loss.data),  # * sample['ntokens'],
        "ntokens": sample["ntokens"],
        "nsentences": sample["target"].size(0),
        "sample_size": sample_size,
        "correct": utils.item(correct.data),
        "total": utils.item(total.data),
        "nframes": torch.sum(sample["net_input"]["src_lengths"]).item(),
    }
    return sample_size, logging_output