def get_basis(vectors, vector_num, vector_len):
    """Get vectors basis

    Args:
        vectors (:obj:`list` of :obj:`int`): The list of
            vectors.
        vector_num (int): The number of vectors in the list.
        vector_len (int): The length of vectors in the list.

    Returns:
        :rtype: (:obj:`list` of :obj:`int`, int): The list of
            basis vectors and the rank of the basis.

    """
    # Initial rank equals to the current full rank
    rank = min(vector_len, vector_num)

    for r in range(rank):
        vectors = sorted(vectors, reverse=True)
        index = len(bin(vectors[r])[2:]) - 1
        for i in range(vector_num):
            if (vectors[i] & 1 << index) and (i != r):
                vectors[i] ^= vectors[r]

    basis = [vectors[i] for i in range(rank) if vectors[i]]
    # The final rank equals to the number of rows in basis matrix
    rank = len(basis)
    return (basis, rank)