def parse_dims_as_set(
    dim: Dims,
    all_dims: set[Hashable],
    *,
    check_exists: bool = True,
    replace_none: bool = True,
) -> set[Hashable] | None | EllipsisType:
    """Like parse_dims_as_tuple, but returning a set instead of a tuple."""
    # TODO: Consider removing parse_dims_as_tuple?
    if dim is None or dim is ...:
        if replace_none:
            return all_dims
        return dim
    if isinstance(dim, str):
        dim = {dim}
    dim = set(dim)
    if check_exists:
        _check_dims(dim, all_dims)
    return dim
Like parse_dims_as_tuple, but returning a set instead of a tuple.
xarray/core/utils.py