import torch


def get_bert_sentence_embeddings(encoded_layers):
    """Obtain sentence embeddings by averaging all embeddings in the second last layer for a sentence."""
    sent_emb = torch.mean(encoded_layers[-2], 1)
    return sent_emb[0]