def crf_viterbi_accuracy(y_true, y_pred):
    """
    Use Viterbi algorithm to get best path, and compute its accuracy.
    `y_pred` must be an output from CRF.
    """
    crf, idx = y_pred._keras_history[:2]
    return crf.get_accuracy(y_true, y_pred)
