from typing import List


def span_labels_to_tag_labels(
    labels: List[str], label_encoding: str = "BIO"
) -> List[str]:
    """Converts a list of span labels to tag labels following `spacy.gold.biluo_tags_from_offsets`

    Parameters
    ----------
    labels
        Span labels to convert
    label_encoding
        The label format used for the tag labels

    Returns
    -------
    tag_labels
    """
    if label_encoding == "BIOUL":
        converted_labels = [
            f"{char}-{label}" for char in ["B", "I", "U", "L"] for label in labels
        ] + ["O"]
    elif label_encoding == "BIO":
        converted_labels = [
            f"{char}-{label}" for char in ["B", "I"] for label in labels
        ] + ["O"]
    else:
        raise ValueError(
            f"'{label_encoding}' is not a supported label encoding scheme."
        )

    return converted_labels