code: def generate(
      self,
      inputs: Optional[torch.Tensor] = None,
      max_length: Optional[int] = None,
      min_length: Optional[int] = None,
      do_sample: Optional[bool] = None,
      early_stopping: Optional[bool] = None,
      num_beams: Optional[int] = 1,
      temperature: Optional[float] = None,
      penalty_alpha: Optional[float] = None,
      top_k: Optional[int] = None,
      top_p: Optional[float] = None,
      typical_p: Optional[float] = None,
      repetition_penalty: Optional[float] = None,
      bad_words_ids: Optional[Iterable[int]] = None,
      force_words_ids: Optional[
          Union[Iterable[int], Iterable[Iterable[int]]]
      ] = None,
      bos_token_id: Optional[int] = None,
      pad_token_id: Optional[int] = None,
      eos_token_id: Optional[int] = None,
      length_penalty: Optional[float] = None,
      no_repeat_ngram_size: Optional[int] = None,
      encoder_no_repeat_ngram_size: Optional[int] = None,
      num_return_sequences: Optional[int] = None,
      max_time: Optional[float] = None,
      max_new_tokens: Optional[int] = None,
      decoder_start_token_id: Optional[int] = None,
      use_cache: Optional[bool] = None,
      num_beam_groups: Optional[int] = None,
      diversity_penalty: Optional[float] = None,
      prefix_allowed_tokens_fn: Optional[
          Callable[[int, torch.Tensor], List[int]]
      ] = None,
      # logits_processor: Optional[LogitsProcessorList] = None,
      # renormalize_logits: Optional[bool] = None,
      # stopping_criteria: Optional[StoppingCriteriaList] = None,
      # constraints: Optional[List[Constraint]] = None,
      output_attentions: Optional[bool] = None,
      output_hidden_states: Optional[bool] = None,
      output_scores: Optional[bool] = None,
      return_dict_in_generate: Optional[bool] = None,
      forced_bos_token_id: Optional[int] = None,
      forced_eos_token_id: Optional[int] = None,
      remove_invalid_values: Optional[bool] = None,
      synced_gpus: Optional[bool] = False,
      exponential_decay_length_penalty: Optional[
          Tuple[int, float]
      ] = None,
      suppress_tokens: Optional[List[int]] = None,
      begin_suppress_tokens: Optional[List[int]] = None,
      forced_decoder_ids: Optional[List[List[int]]] = None,
  ):
      input_lengths = torch.tensor(
          [len(input) for input in inputs],
          dtype=torch.int32,
          device=self.model.device,
      )
      batch_size = len(inputs)
  
      def convert_to_tensor_if_not(value, dtype=torch.float32):
          if value is None:
              return value
          if isinstance(value, torch.Tensor):
              return value
          return value * torch.ones(
              batch_size, dtype=dtype
          )  # cpu tensor
  
      top_k = convert_to_tensor_if_not(top_k, dtype=torch.int32)
      top_p = convert_to_tensor_if_not(top_p, dtype=torch.float32)
      temperature = convert_to_tensor_if_not(
          temperature, dtype=torch.float32
      )
      repetition_penalty = convert_to_tensor_if_not(
          repetition_penalty, dtype=torch.float32
      )
      min_length = convert_to_tensor_if_not(
          min_length, dtype=torch.int32
      )
      len_penalty = convert_to_tensor_if_not(
          length_penalty, dtype=torch.float32
      )
      if max_length is None:
          # gen_length is required for faster transformer
          # infer it from the model config
          max_length = self.config.n_ctx
      output_dict = self.model.generate(
          input_token_ids=inputs,
          input_lengths=input_lengths,
          gen_length=max_length - len(inputs[0]),
          eos_token_id=eos_token_id,
          # local_batch_size=None,
          beam_width=num_beams,
          top_k=top_k,
          top_p=top_p,
          # top_p_decay: Optional[torch.FloatTensor] = None,
          # top_p_min: Optional[torch.FloatTensor] = None,
          # top_p_reset_ids: Optional[torch.IntTensor] = None,
          temperature=temperature,
          repetition_penalty=repetition_penalty,
          # presence_penalty: Optional[torch.FloatTensor] = None,
          min_length=min_length,
          len_penalty=len_penalty,
          # beam_search_diversity_rate: Optional[torch.FloatTensor] = None,
          # stop_words_list: Optional[torch.IntTensor] = None,
          # bad_words_list: Optional[torch.IntTensor] = None,
          # sequence_limit_lengths: Optional[torch.IntTensor] = None,
          # random_seed: Optional[torch.LongTensor] = None,
          # memory_length: Optional[int] = None,
          return_output_length=True,
          return_log_probs=False,
      )
      output_token_ids = output_dict["output_token_ids"]
      output_lengths = output_dict["output_lengths"]
      # tokens = output_token_ids[0, 0, input_lengths[0]:output_lengths[0]]
      tokens = [
          # output_token_ids[i, 0, input_lengths[i]:output_lengths[i]]
          output_token_ids[i, 0, : output_lengths[i]]
          for i in range(batch_size)
      ]
      return tokens
  
file_path: nebuly/optimization/nebullvm/nebullvm/operations/optimizations/compilers/faster_transformer/gpt/__init__.py
imports: import os
  import tempfile
  from typing import Callable, Iterable, List, Optional, Tuple, Union
  from nebullvm.operations.optimizations.compilers.faster_transformer.gpt.utils import gpt_decoder
  from nebullvm.operations.optimizations.compilers.faster_transformer.gpt.utils.huggingface_gpt_convert import main
  from nebullvm.operations.optimizations.compilers.utils import get_faster_transformer_repo_path
  from nebullvm.optional_modules.huggingface import GPT2LMHeadModel
  from nebullvm.optional_modules.torch import torch
label_desc: Use image node_id 2 for calling the FasterTransformerGPT2Wrapper obj's underlying member method code with example usage: obj.generate(inputs, max_length, min_length, do_sample, early_stopping, num_beams, temperature, penalty_alpha, top_k, top_p, typical_p, repetition_penalty, bad_words_ids, force_words_ids, bos_token_id, pad_token_id, eos_token_id, length_penalty, no_repeat_ngram_size, encoder_no_repeat_ngram_size, num_return_sequences, max_time, max_new_tokens, decoder_start_token_id, use_cache, num_beam_groups, diversity_penalty, prefix_allowed_tokens_fn, output_attentions, output_hidden_states, output_scores, return_dict_in_generate, forced_bos_token_id, forced_eos_token_id, remove_invalid_values, synced_gpus, exponential_decay_length_penalty, suppress_tokens, begin_suppress_tokens, forced_decoder_ids) and returns: tokens, unknown, value, value