code: def is_space_counted(words_with_offsets):
      """
      Some tokenizers will count space into words for example.
      Given text: 'hello world', normal bert will output: [('hello', (0, 5)), ('world', (6, 11))]
      while some checkpoint will output: [('▁hello', (0, 5)), ('▁world', (5, 11))]
      This will lead to inconsistency issue during labelling, details can be found here:
      https://github.com/huggingface/transformers/issues/18111
  
      This function will check whether space is counted or not and realign the offset.
      """
      offset0, offset1 = [], []
      for word, offset in words_with_offsets:
          offset0.append(offset[0])
          offset1.append(offset[1])
  
      realign = []
      if offset0[1:] == offset1[:-1]:  # space are counted
          realign = [words_with_offsets[0]]
          for word, offset in words_with_offsets[1:]:
              if word.startswith(
                  "▁"
              ):  # it is "Lower One Eighth Block" (U+2581) rather than lower line (U+005F).
                  realign.append((word, (offset[0] + 1, offset[1])))
              else:
                  realign.append((word, offset))
  
      if realign:
          return realign
      else:
          return words_with_offsets
  
imports: import ast
  import codecs
  import copy
  import re
  import warnings
  from io import BytesIO
  from typing import Callable, Dict, Iterable, List, Optional, Tuple, Union
  import numpy
  import pandas
  import PIL
  from omegaconf import ListConfig
  from text_unidecode import unidecode
  from timm.data.constants import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD, IMAGENET_INCEPTION_MEAN, IMAGENET_INCEPTION_STD
  from tokenizers import pre_tokenizers
  from torchvision import transforms
  from ..constants import CLIP_IMAGE_MEAN, CLIP_IMAGE_STD, IDENTIFIER, IMAGE, IMAGE_BYTEARRAY, IMAGE_PATH, MMDET_IMAGE, MMLAB_MODELS
  from .collator import DictCollator
  from .preprocess_dataframe import MultiModalFeaturePreprocessor
  from .randaug import RandAugment
  from .trivial_augmenter import TrivialAugment
label_desc: Use image node_id 10 for calling a global function with example usage: is_space_counted(words_with_offsets) and returns: realign, words_with_offsets