Return subsets of given set with given cardinality.
    :param k: Cardinality of subsets to return
    :return: Iterable containing all ``k``-subsets of given set

def k_subsets(set_, k):
    """Return subsets of given set with given cardinality.
    :param k: Cardinality of subsets to return
    :return: Iterable containing all ``k``-subsets of given set
    """
    ensure_countable(set_)

    if not isinstance(k, Integral):
        raise TypeError("subset cardinality must be a number")
    if not (k >= 0):
        raise ValueError("subset cardinality must be positive")
    if not (k <= len(set_)):
        raise ValueError("subset cardinality must not exceed set cardinality")

    result = combinations(set_, k)
    return _harmonize_subset_types(set_, result)