code: def test_offsets_mapping(self):
      for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
          with self.subTest(
              f"{tokenizer.__class__.__name__} ({pretrained_name})"
          ):
              tokenizer_r = self.rust_tokenizer_class.from_pretrained(
                  pretrained_name, **kwargs
              )
  
              text = ["a", "wonderful", "test"]
              boxes = [[1, 8, 12, 20] for _ in range(len(text))]
  
              # No pair
              tokens_with_offsets = tokenizer_r.encode_plus(
                  text,
                  boxes=boxes,
                  return_special_tokens_mask=True,
                  return_offsets_mapping=True,
                  add_special_tokens=True,
              )
              added_tokens = tokenizer_r.num_special_tokens_to_add(
                  False
              )
              offsets = tokens_with_offsets["offset_mapping"]
  
              # Assert there is the same number of tokens and offsets
              self.assertEqual(
                  len(offsets), len(tokens_with_offsets["input_ids"])
              )
  
              # Assert there is online added_tokens special_tokens
              self.assertEqual(
                  sum(tokens_with_offsets["special_tokens_mask"]),
                  added_tokens,
              )
  
              # Pairs
              text = "what's his name"
              pair = ["a", "wonderful", "test"]
              boxes = [[1, 8, 12, 20] for _ in range(len(pair))]
              tokens_with_offsets = tokenizer_r.encode_plus(
                  text,
                  pair,
                  boxes=boxes,
                  return_special_tokens_mask=True,
                  return_offsets_mapping=True,
                  add_special_tokens=True,
              )
              added_tokens = tokenizer_r.num_special_tokens_to_add(True)
              offsets = tokens_with_offsets["offset_mapping"]
  
              # Assert there is the same number of tokens and offsets
              self.assertEqual(
                  len(offsets), len(tokens_with_offsets["input_ids"])
              )
  
              # Assert there is online added_tokens special_tokens
              self.assertEqual(
                  sum(tokens_with_offsets["special_tokens_mask"]),
                  added_tokens,
              )
  
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 33 for calling the LayoutXLMTokenizationTest obj's underlying member method code with example usage: obj.test_offsets_mapping() without return types