code: def test_alignments_match(words1, words2):
      spans = get_spans(words1)
      align = get_alignment(spans, words2)
      unique_tokens = set()
      for span in spans:
          for token in span:
              unique_tokens.add((id(token.doc), token.idx))
      assert len(unique_tokens) == align.lengths.shape[0]
      flat_words1, flat_words2 = flatten_strings(words1, words2)
      for i, word in enumerate(flat_words1):
          wp_word = "".join(
              [flat_words2[int(j[0])] for j in align[i].data]
          )
          if len(word) < len(wp_word):
              assert word in wp_word
          elif len(word) > len(wp_word):
              assert wp_word in word
          else:
              assert word == wp_word
  
file_path: spacy-transformers/spacy_transformers/tests/test_alignment.py
imports: import pytest
  from typing import List
  import numpy
  from spacy.tokens import Doc
  from spacy.vocab import Vocab
  from thinc.api import NumpyOps
  from thinc.types import Ragged
  from ..align import get_alignment, apply_alignment
  from ..align import get_span2wp_from_offset_mapping
label_desc: Use image node_id 4 for calling a global function with example usage: test_alignments_match(words1, words2) without return types