Map sentences and labels to vectors based on a pretrained word2vec

def build_input_data_with_word2vec(sentences, labels, word2vec_list):
    """
    Map sentences and labels to vectors based on a pretrained word2vec
    """
    x_vec = []
    for sent in sentences:
        vec = []
        for word in sent:
            if word in word2vec_list:
                vec.append(word2vec_list[word])
            else:
                vec.append(word2vec_list['</s>'])
        x_vec.append(vec)
    x_vec = np.array(x_vec)
    y_vec = np.array(labels)
    return [x_vec, y_vec]