class_docstr: Tokenizes by making a request to the proxy server with REST endpoint: `/api/tokenize`.
docstr: Encodes the input text to tokens.
docstr_tok: ["Encodes","the","input","text","to","tokens","."]
code: def encode(
      self,
      text: str,
      truncation: bool = False,
      max_length: Optional[int] = None,
  ) -> EncodeResult:
      """
      Encodes the input text to tokens.
      """
      tokens: List[TokenizationToken]
      normalized_text: str
      tokens, normalized_text = self._make_long_tokenization_request(
          text
      )
      # The end position of the last token should be the end of the text.
      if len(tokens) > 0:
          assert tokens[-1].text_range is not None
          assert tokens[-1].text_range.end == len(normalized_text)
  
      return EncodeResult(text=normalized_text, tokens=tokens)
  
imports: import re
  from typing import List, Optional, Tuple
  from urllib.parse import unquote
  from helm.common.tokenization_request import TokenizationRequest, TokenizationRequestResult, TokenizationToken, TextRange
  from .window_service import WindowService, EncodeResult
  from .tokenizer_service import TokenizerService
  from .gpt2_window_service import GPT2WindowService
label_desc: Use image node_id 7 for calling the AI21WindowService obj's underlying member method code with example usage: obj.encode(text, truncation, max_length) and returns: EncodeResult