def calc_attention_combination(attention_weights, matrix):
    """Calculate sum of vectors of matrix along dim=1 with coefficients specified by attention_weights.

    :param attention_weights: size - [batch_size, seq_len, 1]
    :param matrix: size - [batch_size, seq_len, vector_dim]
    :return: matrix of size [batch_size, vector_dim]
    """
    return attention_weights.transpose(1, 2).matmul(matrix).squeeze(1)