class_docstr: A class containing all functions for auto-regressive text generation
  
  Pass custom parameter values to 'generate' .
docstr: Create a generator of tokens from a prompt.
  
  Examples:
      >>> llm = AutoModelForCausalLM.from_pretrained("gpt4all-model-q4_0.bin",
                                                     model_family="llama")
      >>> tokens = llm.tokenize("Q: Tell me something about Intel. A:")
      >>> tokens_id = llm.generate(tokens, max_new_tokens=32)
      >>> llm.batch_decode(tokens_id)
  
  Args:
      tokens: The prompt tokens.
      top_k: The top-k sampling parameter.
      top_p: The top-p sampling parameter.
      temp: The temperature parameter.
      repeat_penalty: The repeat penalty parameter.
      reset: Whether to reset the model state.
  
  Yields:
      The generated tokens.
docstr_tok: ["Create","a","generator","of","tokens","from","a","prompt",".","Examples",":",">",">",">","llm","=","AutoModelForCausalLM.from_pretrained","(","``","gpt4all-model-q4_0.bin","''",",","model_family=","''","llama","''",")",">",">",">","tokens","=","llm.tokenize","(","``","Q",":","Tell","me","something","about","Intel",".","A",":","''",")",">",">",">","tokens_id","=","llm.generate","(","tokens",",","max_new_tokens=32",")",">",">",">","llm.batch_decode","(","tokens_id",")","Args",":","tokens",":","The","prompt","tokens",".","top_k",":","The","top-k","sampling","parameter",".","top_p",":","The","top-p","sampling","parameter",".","temp",":","The","temperature","parameter",".","repeat_penalty",":","The","repeat","penalty","parameter",".","reset",":","Whether","to","reset","the","model","state",".","Yields",":","The","generated","tokens","."]
code: def generate(
      self,
      inputs: Optional[
          Union[Sequence[int], Sequence[Sequence[int]], torch.Tensor]
      ] = None,
      max_new_tokens: int = 128,
      top_k: int = 40,
      top_p: float = 0.95,
      temperature: float = 0.80,
      repetition_penalty: float = 1.1,
      reset: bool = True,
      frequency_penalty: float = 0.0,
      presence_penalty: float = 0.0,
      tfs_z: float = 1.0,
      mirostat_mode: int = 0,
      mirostat_tau: float = 5.0,
      mirostat_eta: float = 0.1,
      stop: Optional[
          Union[str, List[str]]
      ] = [],  # TODO: rebase to support stopping_criteria
      **kwargs,
  ) -> Optional[Union[Sequence[int], Sequence[Sequence[int]], None]]:
      # TODO: modify docs
      """Create a generator of tokens from a prompt.
  
      Examples:
          >>> llm = AutoModelForCausalLM.from_pretrained("gpt4all-model-q4_0.bin",
                                                         model_family="llama")
          >>> tokens = llm.tokenize("Q: Tell me something about Intel. A:")
          >>> tokens_id = llm.generate(tokens, max_new_tokens=32)
          >>> llm.batch_decode(tokens_id)
  
      Args:
          tokens: The prompt tokens.
          top_k: The top-k sampling parameter.
          top_p: The top-p sampling parameter.
          temp: The temperature parameter.
          repeat_penalty: The repeat penalty parameter.
          reset: Whether to reset the model state.
  
      Yields:
          The generated tokens.
      """
      if isinstance(inputs, torch.Tensor):
          inputs = inputs.tolist()
      if inputs and len(inputs) > 0:
          if not isinstance(inputs[0], Sequence):
              inputs = [inputs]
      else:
          return None
  
      results = []
      for input in inputs:
          tokens = self._generate(
              tokens=input,
              top_k=top_k,
              top_p=top_p,
              temp=temperature,
              repeat_penalty=repetition_penalty,
              reset=reset,
              frequency_penalty=frequency_penalty,
              presence_penalty=presence_penalty,
              tfs_z=tfs_z,
              mirostat_mode=mirostat_mode,
              mirostat_tau=mirostat_tau,
              mirostat_eta=mirostat_eta,
              **kwargs,
          )
          res_list = []
          word_count = 0
          for token in tokens:
              if word_count >= max_new_tokens:
                  break
              res_list.append(token)
              word_count += 1
          results.append(res_list)
  
      return results
  
imports: from typing import Optional, Union, Sequence, List
  from bigdl.llm.utils.common import invalidInputError
  import torch
label_desc: Use image node_id 4 for calling the GenerationMixin obj's underlying member method code with example usage: obj.generate(inputs, max_new_tokens, top_k, top_p, temperature, repetition_penalty, reset, frequency_penalty, presence_penalty, tfs_z, mirostat_mode, mirostat_tau, mirostat_eta, stop) and returns: results, None