code: def test_lm_split(lang_model, head_gt, num_tokens):
      """
      Check if the split head-tail is correctly performed
      """
      # define a very long word as tail
      tail = "Pneumonoultramicroscopicsilicovolcanoconiosis " * 100
      text = head_gt + " " + tail
  
      # split head tail
      head, tail, head_tokens, tail_tokens = lang_model.head_tail_split(
          text
      )
  
      # get the unique words in head
      unique_words = set(head.strip().split(" "))
      assert len(unique_words) == num_tokens
  
imports: import pytest
  from pytest_lazyfixture import lazy_fixture
  import string
  import numpy
  from typing import List
  from alibi.api.defaults import DEFAULT_META_ANCHOR, DEFAULT_DATA_ANCHOR
  from alibi.exceptions import PredictorCallError, PredictorReturnTypeError
  from alibi.explainers import AnchorText
  from alibi.explainers.anchors.text_samplers import Neighbors, load_spacy_lexeme_prob
  from alibi.explainers.anchors.language_model_text_sampler import LanguageModelSampler
  from alibi.explainers.tests.utils import predict_fcn
label_desc: Use image node_id 8 for calling a global function with example usage: test_lm_split(lang_model, head_gt, num_tokens) without return types