'Test two batch entries - best path decoder.'

def test_ctc_decode_greedy(self):

    max_time_steps = 6
    seq_len_0 = 4
    input_prob_matrix_0 = np.asarray([[1.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.4, 0.6], [0.0, 0.0, 0.4, 0.6], [0.0, 0.9, 0.1, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]], dtype=np.float32)
    input_log_prob_matrix_0 = np.log(input_prob_matrix_0)
    seq_len_1 = 5
    input_prob_matrix_1 = np.asarray([[0.1, 0.9, 0.0, 0.0], [0.0, 0.9, 0.1, 0.0], [0.0, 0.0, 0.1, 0.9], [0.0, 0.9, 0.1, 0.1], [0.9, 0.1, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]], dtype=np.float32)
    inputs = [np.vstack([input_prob_matrix_0[t, :], input_prob_matrix_1[t, :]]) for t in range(max_time_steps)]
    inputs = KTF.variable(np.asarray(inputs).transpose((1, 0, 2)))
    input_length = KTF.variable(np.array([seq_len_0, seq_len_1], dtype=np.int32))
    log_prob_truth = np.array([np.sum((- np.log([1.0, 0.6, 0.6, 0.9]))), np.sum((- np.log([0.9, 0.9, 0.9, 0.9, 0.9])))], np.float32)[:, np.newaxis]
    decode_truth = np.array([[0, 1, (-1)], [1, 1, 0]])
    (decode_pred_tf, log_prob_pred_tf) = KTF.ctc_decode(inputs, input_length, greedy=True)
    assert (len(decode_pred_tf) == 1)
    decode_pred = KTF.eval(decode_pred_tf[0])
    log_prob_pred = KTF.eval(log_prob_pred_tf)
    assert np.alltrue((decode_truth == decode_pred))
    assert np.allclose(log_prob_truth, log_prob_pred)
