class_docstr: High-level Python wrapper for a gptneox.cpp model.
class_docstr_tok: ["High-level","Python","wrapper","for","a","gptneox.cpp","model","."]
docstr: Tokenize a string.
  
  Args:
      text: The utf-8 encoded string to tokenize.
  
  Raises:
      RuntimeError: If the tokenization failed.
  
  Returns:
      A list of tokens.
docstr_tok: ["Tokenize","a","string",".","Args",":","text",":","The","utf-8","encoded","string","to","tokenize",".","Raises",":","RuntimeError",":","If","the","tokenization","failed",".","Returns",":","A","list","of","tokens","."]
code: def _tokenize(
      self, text: bytes, add_bos: bool = True
  ) -> List[gptneox_cpp.gptneox_token]:
      """Tokenize a string.
  
      Args:
          text: The utf-8 encoded string to tokenize.
  
      Raises:
          RuntimeError: If the tokenization failed.
  
      Returns:
          A list of tokens.
      """
      invalidInputError(
          self.ctx is not None,
          "The attribute `ctx` of `Gptneox` object is None.",
      )
      n_ctx = gptneox_cpp.gptneox_n_ctx(self.ctx)
      tokens = (gptneox_cpp.gptneox_token * int(n_ctx))()
      n_tokens = gptneox_cpp.gptneox_tokenize(
          self.ctx,
          text,
          tokens,
          n_ctx,
          gptneox_cpp.c_bool(add_bos),
      )
      if int(n_tokens) < 0:
          n_tokens = abs(n_tokens)
          tokens = (gptneox_cpp.gptneox_token * int(n_tokens))()
          n_tokens = gptneox_cpp.gptneox_tokenize(
              self.ctx,
              text,
              tokens,
              gptneox_cpp.c_int(n_tokens),
              gptneox_cpp.c_bool(add_bos),
          )
          invalidInputError(
              n_tokens >= 0,
              f'Failed to tokenize: text="{text}" n_tokens={n_tokens}.',
          )
      return list(tokens[:n_tokens])
  
imports: import os
  import sys
  import uuid
  import time
  import math
  import multiprocessing
  import ctypes
  from typing import List, Optional, Union, Generator, Sequence, Iterator, Deque, Tuple
  from collections import deque, OrderedDict
  from bigdl.llm.utils.common import invalidInputError
  from bigdl.llm.ggml.model.generation import GenerationMixin
  from .None import gptneox_cpp
  from .gptneox_types import *
label_desc: Use image node_id 2 for calling the Gptneox obj's underlying member method code with example usage: obj._tokenize(text, add_bos) and returns: list