def to_tags(self, spans: List[Tuple[str, int, int]]) -> List[str]:
        """Convert spans to IOB tags.

        Args:
            spans: Spans to transform into IOB tags.

        Returns:
            The IOB tags.

        Raises:
            ValueError: If spans overlap, the IOB format does not support overlapping spans.
        """
        # check for overlapping spans
        sorted_spans = sorted(spans, key=lambda x: x[1])
        for i in range(1, len(spans)):
            if sorted_spans[i - 1][2] > sorted_spans[i][1]:
                raise ValueError("IOB tags cannot handle overlapping spans!")

        tags = ["O"] * len(self.tokens)
        for span in spans:
            start_token_idx = self._start_to_token_idx[span[1]]
            end_token_idx = self._end_to_token_idx[span[2]]

            tags[start_token_idx] = f"B-{span[0]}"
            for token_idx in range(start_token_idx + 1, end_token_idx + 1):
                tags[token_idx] = f"I-{span[0]}"

        return tags
Convert spans to IOB tags.

        Args:
            spans: Spans to transform into IOB tags.

        Returns:
            The IOB tags.

        Raises:
            ValueError: If spans overlap, the IOB format does not support overlapping spans.
        
argilla-v1/src/argilla_v1/utils/span_utils.py