def METHOD_NAME(self, model, sample, reduce=True):
    mode = sample["net_input"]["mode"]
    if mode == "sup_speech_ctc":  # CTC
        sample["net_input"][
            "src_lengths"
        ] = None  # get downsampled src_lengths from padding_mask
        loss, sample_size, logging_output = self.ctc(model, sample, reduce)
        logging_output["mode"] = SpeechTextPreTrainCompoundCriterion.mode2value(
            "CTC"
        )
    else:
        loss, sample_size, logging_output = self.xent(model, sample, reduce)
        logging_output["mode"] = SpeechTextPreTrainCompoundCriterion.mode2value(
            "xent"
        )
    return loss, sample_size, logging_output