class_docstr: Apply the Moses Tokenizer/Detokenizer implemented in
   [sacremoses](https://github.com/alvations/sacremoses).
  
  .. note::
      sacremoses carries an LGPL 2.1+ license.
  
  Parameters
  ----------
  lang
      The language of the input.
class_docstr_tok: ["Apply","the","Moses","Tokenizer\/Detokenizer","implemented","in","[","sacremoses","]","(","https",":","\/\/github.com\/alvations\/sacremoses",")",".","..","note",":",":","sacremoses","carries","an","LGPL","2.1+","license",".","Parameters","--","--","--","--","--","lang","The","language","of","the","input","."]
code: def encode(self, sentences, output_type=str):
      if output_type is str:
          if isinstance(sentences, list):
              return [
                  self._tokenizer.tokenize(sentence, return_str=False)
                  for sentence in sentences
              ]
          else:
              return self._tokenizer.tokenize(
                  sentences, return_str=False
              )
      elif output_type is int:
          if self._vocab is None:
              raise TokenizerEncodeWithoutVocabError
          tokens = self.encode(sentences, str)
          if isinstance(sentences, list):
              return [self._vocab[ele_tokens] for ele_tokens in tokens]
          else:
              return self._vocab[tokens]
      else:
          raise NotImplementedError
  
file_path: gluon-nlp/src/gluonnlp/data/tokenizers/moses.py
imports: from typing import Optional
  import warnings
  import sacremoses
  from .base import TOKENIZER_REGISTRY, BaseTokenizerWithVocab, TokenizerEncodeWithoutVocabError, TokenizerDecodeWithoutVocabError, TokenTypeNotSupportedError, is_tokens_from_multiple_sentences, get_token_type
  from ..vocab import Vocab
label_desc: Use image node_id 3 for calling the MosesTokenizer obj's underlying member method code with example usage: obj.encode(sentences, output_type) and returns: unknown, self, unknown, self