code: def hf_encode_with_offsets(model, sentences, output_type: type = str):
      is_multi_sentences = isinstance(sentences, list)
      if not is_multi_sentences:
          sentences = [sentences]
      encode_sentences = model.encode_batch(
          sentences, add_special_tokens=False
      )
      if output_type is str:
          ret = [
              encode_sentence.tokens
              for encode_sentence in encode_sentences
          ]
          offsets = [
              encode_sentence.offsets
              for encode_sentence in encode_sentences
          ]
      elif output_type is int:
          ret = [
              encode_sentence.ids
              for encode_sentence in encode_sentences
          ]
          offsets = [
              encode_sentence.offsets
              for encode_sentence in encode_sentences
          ]
      else:
          raise TokenTypeNotSupportedError(output_type)
      if is_multi_sentences:
          return ret, offsets
      else:
          return ret[0], offsets[0]
  
imports: import os
  import json
  from pkg_resources import parse_version
  from typing import Optional, Union, List, Tuple
  from collections import OrderedDict
  from uuid import uuid4
  from .base import *
  from ..vocab import Vocab, load_vocab
  from ...utils.lazy_imports import try_import_huggingface_tokenizers
label_desc: Use image node_id 3 for calling a global function with example usage: hf_encode_with_offsets(model, sentences, output_type) and returns: ret,  offsets, ret,  offsets