code: def test_alignment_spaces(en_vocab):
      # single leading whitespace
      other_tokens = [
          " ",
          "i listened to",
          "obama",
          "'",
          "s",
          "podcasts",
          ".",
      ]
      spacy_tokens = ["i", "listened", "to", "obama", "'s", "podcasts."]
      align = Alignment.from_strings(other_tokens, spacy_tokens)
      assert list(align.x2y.lengths) == [0, 3, 1, 1, 1, 1, 1]
      assert list(align.x2y.data) == [0, 1, 2, 3, 4, 4, 5, 5]
      assert list(align.y2x.lengths) == [1, 1, 1, 1, 2, 2]
      assert list(align.y2x.data) == [1, 1, 1, 2, 3, 4, 5, 6]
  
      # multiple leading whitespace tokens
      other_tokens = [
          " ",
          " ",
          "i listened to",
          "obama",
          "'",
          "s",
          "podcasts",
          ".",
      ]
      spacy_tokens = ["i", "listened", "to", "obama", "'s", "podcasts."]
      align = Alignment.from_strings(other_tokens, spacy_tokens)
      assert list(align.x2y.lengths) == [0, 0, 3, 1, 1, 1, 1, 1]
      assert list(align.x2y.data) == [0, 1, 2, 3, 4, 4, 5, 5]
      assert list(align.y2x.lengths) == [1, 1, 1, 1, 2, 2]
      assert list(align.y2x.data) == [2, 2, 2, 3, 4, 5, 6, 7]
  
      # both with leading whitespace, not identical
      other_tokens = [
          " ",
          " ",
          "i listened to",
          "obama",
          "'",
          "s",
          "podcasts",
          ".",
      ]
      spacy_tokens = [
          " ",
          "i",
          "listened",
          "to",
          "obama",
          "'s",
          "podcasts.",
      ]
      align = Alignment.from_strings(other_tokens, spacy_tokens)
      assert list(align.x2y.lengths) == [1, 0, 3, 1, 1, 1, 1, 1]
      assert list(align.x2y.data) == [0, 1, 2, 3, 4, 5, 5, 6, 6]
      assert list(align.y2x.lengths) == [1, 1, 1, 1, 1, 2, 2]
      assert list(align.y2x.data) == [0, 2, 2, 2, 3, 4, 5, 6, 7]
  
      # same leading whitespace, different tokenization
      other_tokens = [
          " ",
          " ",
          "i listened to",
          "obama",
          "'",
          "s",
          "podcasts",
          ".",
      ]
      spacy_tokens = [
          "  ",
          "i",
          "listened",
          "to",
          "obama",
          "'s",
          "podcasts.",
      ]
      align = Alignment.from_strings(other_tokens, spacy_tokens)
      assert list(align.x2y.lengths) == [1, 1, 3, 1, 1, 1, 1, 1]
      assert list(align.x2y.data) == [0, 0, 1, 2, 3, 4, 5, 5, 6, 6]
      assert list(align.y2x.lengths) == [2, 1, 1, 1, 1, 2, 2]
      assert list(align.y2x.data) == [0, 1, 2, 2, 2, 3, 4, 5, 6, 7]
  
      # only one with trailing whitespace
      other_tokens = [
          "i listened to",
          "obama",
          "'",
          "s",
          "podcasts",
          ".",
          " ",
      ]
      spacy_tokens = ["i", "listened", "to", "obama", "'s", "podcasts."]
      align = Alignment.from_strings(other_tokens, spacy_tokens)
      assert list(align.x2y.lengths) == [3, 1, 1, 1, 1, 1, 0]
      assert list(align.x2y.data) == [0, 1, 2, 3, 4, 4, 5, 5]
      assert list(align.y2x.lengths) == [1, 1, 1, 1, 2, 2]
      assert list(align.y2x.data) == [0, 0, 0, 1, 2, 3, 4, 5]
  
      # different trailing whitespace
      other_tokens = [
          "i listened to",
          "obama",
          "'",
          "s",
          "podcasts",
          ".",
          " ",
          " ",
      ]
      spacy_tokens = [
          "i",
          "listened",
          "to",
          "obama",
          "'s",
          "podcasts.",
          " ",
      ]
      align = Alignment.from_strings(other_tokens, spacy_tokens)
      assert list(align.x2y.lengths) == [3, 1, 1, 1, 1, 1, 1, 0]
      assert list(align.x2y.data) == [0, 1, 2, 3, 4, 4, 5, 5, 6]
      assert list(align.y2x.lengths) == [1, 1, 1, 1, 2, 2, 1]
      assert list(align.y2x.data) == [0, 0, 0, 1, 2, 3, 4, 5, 6]
  
      # same trailing whitespace, different tokenization
      other_tokens = [
          "i listened to",
          "obama",
          "'",
          "s",
          "podcasts",
          ".",
          " ",
          " ",
      ]
      spacy_tokens = [
          "i",
          "listened",
          "to",
          "obama",
          "'s",
          "podcasts.",
          "  ",
      ]
      align = Alignment.from_strings(other_tokens, spacy_tokens)
      assert list(align.x2y.lengths) == [3, 1, 1, 1, 1, 1, 1, 1]
      assert list(align.x2y.data) == [0, 1, 2, 3, 4, 4, 5, 5, 6, 6]
      assert list(align.y2x.lengths) == [1, 1, 1, 1, 2, 2, 2]
      assert list(align.y2x.data) == [0, 0, 0, 1, 2, 3, 4, 5, 6, 7]
  
      # differing whitespace is allowed
      other_tokens = ["a", " \n ", "b", "c"]
      spacy_tokens = ["a", "b", " ", "c"]
      align = Alignment.from_strings(other_tokens, spacy_tokens)
      assert list(align.x2y.data) == [0, 1, 3]
      assert list(align.y2x.data) == [0, 2, 3]
  
      # other differences in whitespace are allowed
      other_tokens = [" ", "a"]
      spacy_tokens = ["  ", "a", " "]
      align = Alignment.from_strings(other_tokens, spacy_tokens)
  
      other_tokens = ["a", " "]
      spacy_tokens = ["a", "  "]
      align = Alignment.from_strings(other_tokens, spacy_tokens)
  
imports: import random
  import numpy
  import pytest
  import srsly
  from thinc.api import Adam, compounding
  import spacy
  from spacy.lang.en import English
  from spacy.tokens import Doc, DocBin
  from spacy.training import Alignment, Corpus, Example, biluo_tags_to_offsets, biluo_tags_to_spans, docs_to_json, iob_to_biluo, offsets_to_biluo_tags
  from spacy.training.align import get_alignments
  from spacy.training.alignment_array import AlignmentArray
  from spacy.training.converters import json_to_docs
  from spacy.training.loop import train_while_improving
  from spacy.util import get_words_and_spaces, load_config_from_str, load_model_from_path, minibatch
  from ..util import make_tempdir
label_desc: Use image node_id 48 for calling a global function with example usage: test_alignment_spaces(en_vocab) without return types