code: def encode_with_offsets(self, sentences, output_type=str):
      is_multi_sentences = isinstance(sentences, list)
      if not is_multi_sentences:
          sentences = [sentences]
      tokens = []
      token_ids = []
      offsets = []
      for sentence in sentences:
          encode_token = self.transform_sentence(
              self._bpe.segment(
                  sentence, dropout=self._bpe_dropout
              ).split(" ")
          )
          encode_id = self._vocab[encode_token]
          encode_token_without_suffix = [
              x.replace(self._suffix, "") for x in encode_token
          ]
          encode_offset = rebuild_offset_from_tokens(
              sentence, encode_token_without_suffix
          )
          tokens.append(encode_token)
          token_ids.append(encode_id)
          offsets.append(encode_offset)
      if not is_multi_sentences:
          tokens = tokens[0]
          token_ids = token_ids[0]
          offsets = offsets[0]
      if output_type is str:
          return tokens, offsets
      elif output_type is int:
          return token_ids, offsets
      else:
          raise TokenTypeNotSupportedError(output_type)
  
file_path: gluon-nlp/src/gluonnlp/data/tokenizers/subword_nmt.py
imports: import os
  from typing import Optional, Union, List
  from .base import TOKENIZER_REGISTRY, BaseTokenizerWithVocab, TokenizerEncodeWithoutVocabError, TokenizerDecodeWithoutVocabError, TokenTypeNotSupportedError, rebuild_offset_from_tokens, TokensType, TokenIDsType, TokenOffsetsType, SentencesType, is_tokens_from_multiple_sentences, get_token_type
  from ..vocab import Vocab, load_vocab
  from ...utils.lazy_imports import try_import_subword_nmt
label_desc: Use image node_id 4 for calling the SubwordNMTTokenizer obj's underlying member method code with example usage: obj.encode_with_offsets(sentences, output_type) and returns: tokens,  offsets, token_ids,  offsets