def METHOD_NAME(
    self,
    _mode: str,
    x,
    x_len,
    label,
    label_len,
    record_id: str,
    chunk_id: int,
    _dump_dir: str = None,
):
    predicted, predicted_len = self.predict(x, x_len)
    for pl, ll in zip(predicted_len, label_len):
        assert (
            abs(pl - ll) <= TOLERANT_FRAME_DIFF
        ), f"predicted: {pl}, label: {ll}, TOLERANT_FRAME_DIFF: {TOLERANT_FRAME_DIFF}"
    predicted, label = self._match_length(predicted, label)
    loss, perm_idx, perm_list = self.objective(predicted, label.float(), label_len)
    label_perm = get_label_perm(label, perm_idx, perm_list)
    (
        correct,
        num_frames,
        speech_scored,
        speech_miss,
        speech_falarm,
        speaker_scored,
        speaker_miss,
        speaker_falarm,
        speaker_error,
    ) = calc_diarization_error(predicted, label_perm, label_len)
    if speech_scored > 0 and speaker_scored > 0 and num_frames > 0:
        SAD_MR, SAD_FR, MI, FA, CF, ACC, DER = (
            speech_miss / speech_scored,
            speech_falarm / speech_scored,
            speaker_miss / speaker_scored,
            speaker_falarm / speaker_scored,
            speaker_error / speaker_scored,
            correct / num_frames,
            (speaker_miss + speaker_falarm + speaker_error) / speaker_scored,
        )
    else:
        SAD_MR, SAD_FR, MI, FA, CF, ACC, DER = 0, 0, 0, 0, 0, 0, 0
    if _mode == "test" and _dump_dir is not None:
        assert (
            len(set(list(record_id))) == 1
        ), "During testing, all utterances in a batch should come from the same recording"
        if len(label_len) > 1:
            assert (
                len(set(label_len[:-1].tolist())) == 1
            ), f"Except the final chunk, other chunks from the same recording should have the same length"
        predicted_sorted = []
        for idx in chunk_id.long().topk(len(chunk_id), largest=False).indices:
            predicted_sorted.append(predicted[idx])
        predict = torch.vstack(predicted_sorted)
        predict = predict.detach().cpu()
        predict = 1 / (1 + (-predict).exp())
        prediction_dir = Path(_dump_dir) / f"prediction"
        prediction_dir.mkdir(exist_ok=True, parents=True)
        torch.save(predict, prediction_dir / f"{record_id[0]}.pt")
    cacheable = dict(
        loss=loss.detach().cpu(),
        accuracy=ACC,
        der=DER,
    )
    return loss, cacheable