code: def test_only_label_first_subword(self):
      words = ["hello", "niels"]
      boxes = [[1000, 1000, 1000, 1000] for _ in range(len(words))]
      word_labels = [0, 1]
  
      # test slow tokenizer
      tokenizer_p = LayoutXLMTokenizer.from_pretrained(
          "microsoft/layoutxlm-base"
      )
      encoding = tokenizer_p(
          words, boxes=boxes, word_labels=word_labels
      )
      self.assertListEqual(
          encoding.labels, [-100, 0, -100, 1, -100, -100]
      )
  
      tokenizer_p = LayoutXLMTokenizer.from_pretrained(
          "microsoft/layoutxlm-base", only_label_first_subword=False
      )
      encoding = tokenizer_p(
          words, boxes=boxes, word_labels=word_labels
      )
      self.assertListEqual(encoding.labels, [-100, 0, 0, 1, 1, -100])
  
      # test fast tokenizer
      tokenizer_r = LayoutXLMTokenizerFast.from_pretrained(
          "microsoft/layoutxlm-base"
      )
      encoding = tokenizer_r(
          words, boxes=boxes, word_labels=word_labels
      )
      self.assertListEqual(
          encoding.labels, [-100, 0, -100, 1, -100, -100]
      )
  
      tokenizer_r = LayoutXLMTokenizer.from_pretrained(
          "microsoft/layoutxlm-base", only_label_first_subword=False
      )
      encoding = tokenizer_r(
          words, boxes=boxes, word_labels=word_labels
      )
      self.assertListEqual(encoding.labels, [-100, 0, 0, 1, 1, -100])
  
imports: import inspect
  import shutil
  import tempfile
  import unittest
  from typing import List
  from transformers import AddedToken, LayoutXLMTokenizerFast, SpecialTokensMixin, is_tf_available, is_torch_available, logging
  from transformers.models.layoutxlm.tokenization_layoutxlm import LayoutXLMTokenizer
  from transformers.testing_utils import get_tests_dir, is_pt_tf_cross_test, require_pandas, require_scatter, require_sentencepiece, require_tokenizers, require_torch, slow
  from ...test_tokenization_common import SMALL_TRAINING_CORPUS, TokenizerTesterMixin, filter_non_english, merge_model_tokenizer_mappings
label_desc: Use image node_id 55 for calling the LayoutXLMTokenizationTest obj's underlying member method code with example usage: obj.test_only_label_first_subword() without return types