def sequence_word_index(sequence, word_index_dict, pad_value=0):
    """Sequence word transfer to sequence index.
    
    Args:
        sequence: pd.Series or np.array or List of lists, sample sequence.
        word_index_dict: dict, {word: index}.
        pad_value: fillna value, if word not in word_index_dict, fillna it.
    Returns:
        List of lists, sequence word transfer to sequence index list.
    """
    if isinstance(sequence[0], str):
        return [word_index_dict.get(j, pad_value) for j in sequence]
    return [[word_index_dict.get(j, pad_value) for j in i] for i in sequence]