code: def encode(self, sentences, output_type=str):
      is_multi_sentences = isinstance(sentences, list)
      if not is_multi_sentences:
          sentences = [sentences]
      if output_type is str:
          ret = [
              self.transform_sentence(
                  self._bpe.segment(
                      sentence, dropout=self._bpe_dropout
                  ).split(" ")
              )
              for sentence in sentences
          ]
      elif output_type is int:
          if self._vocab is None:
              raise TokenizerEncodeWithoutVocabError
          ret = [
              self._vocab[
                  self.transform_sentence(
                      self._bpe.segment(
                          sentence, dropout=self._bpe_dropout
                      ).split(" ")
                  )
              ]
              for sentence in sentences
          ]
      else:
          raise TokenTypeNotSupportedError(output_type)
      if is_multi_sentences:
          return ret
      else:
          return ret[0]
  
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 3 for calling the SubwordNMTTokenizer obj's underlying member method code with example usage: obj.encode(sentences, output_type) and returns: ret, ret