def _sanitize_str_to_list(dim):
    """Make dim to list if string, pass if None else raise ValueError."""
    if isinstance(dim, str):
        dim = [dim]
    elif isinstance(dim, list) or dim is None:
        dim = dim
    else:
        raise ValueError(
            f"Expected `dim` as `str`, `list` or None, found {dim} as type {type(dim)}."
        )
    return dim