class_docstr: Holds utility methods to work with a tokenized text and entity spans.
  
  Spans must be tuples containing the label (str), start char idx (int), and end char idx (int).
  
  Args:
      text: The text the spans refer to.
      tokens: The tokens of the text.
docstr: Validates the alignment of span boundaries and tokens.
  
  Args:
      spans: A list of spans.
  
  Raises:
      ValueError: If a span is invalid, or if a span is not aligned with the tokens.
docstr_tok: ["Validates","the","alignment","of","span","boundaries","and","tokens",".","Args",":","spans",":","A","list","of","spans",".","Raises",":","ValueError",":","If","a","span","is","invalid",",","or","if","a","span","is","not","aligned","with","the","tokens","."]
code: def validate(self, spans: List[Tuple[str, int, int]]):
      """Validates the alignment of span boundaries and tokens.
  
      Args:
          spans: A list of spans.
  
      Raises:
          ValueError: If a span is invalid, or if a span is not aligned with the tokens.
      """
      not_valid_spans_errors, misaligned_spans_errors = [], []
  
      for span in spans:
          char_start, char_end = span[1], span[2]
          if char_end - char_start < 1:
              not_valid_spans_errors.append(span)
          elif None in (
              self._start_to_token_idx.get(char_start),
              self._end_to_token_idx.get(char_end),
          ):
              span_str = self.text[char_start:char_end]
              message = f"{span} - {repr(span_str)}"
              misaligned_spans_errors.append(message)
  
      if not_valid_spans_errors or misaligned_spans_errors:
          message = ""
          if not_valid_spans_errors:
              message += f"Following entity spans are not valid: {not_valid_spans_errors}\n"
  
          if misaligned_spans_errors:
              spans = "\n".join(misaligned_spans_errors)
              message += "Following entity spans are not aligned with provided tokenization\n"
              message += f"Spans:\n{spans}\n"
              message += f"Tokens:\n{self.tokens}"
  
          raise ValueError(message)
  
file_path: argilla/src/argilla/utils/span_utils.py
imports: from typing import Dict, List, Optional, Tuple
label_desc: Use image node_id 6 for calling the SpanUtils obj's underlying member method code with example usage: obj.validate(spans) without return types