class_docstr: This wrapper utility function implements a single beam search to generate efficiently text.
  A lot of the credit goes to the huggingface team and its chief scientist Thomas Wolf whose implementation I based
  myself off.
  
  Args:
      encoder: huggingface encoder or onnx session for the encoder of T5. Can be obtained with the
          create_t5_encoder_decoder utility function for pytorch, see examples below.
      decoder_with_lm_head: decoder with language model head on top. Can be obtained with the
          create_t5_encoder_decoder utility function for pytorch, see examples below.
      tokenizer: huggingface tokenizer
      onnx (bool): whether to use onnx or the default pytorch
      cuda (bool): whether to use cuda or the cpu
  
  Examples:
      For pytorch:
      >>> from transformers import T5Tokenizer
      >>> from onnxt5 import create_t5_encoder_decoder, GenerativeT5
      >>> pretrained_model = 't5-base' # This can be a pretrained version, or the path to a huggingface model
      >>> simplified_encoder, decoder_with_lm_head = create_t5_encoder_decoder(pretrained_model)
      >>> tokenizer = T5Tokenizer.from_pretrained(pretrained_model)
      >>> generative_t5 = GenerativeT5(simplified_encoder, decoder_with_lm_head, tokenizer)
      >>> generative_t5('translate English to French: I was a victim of a series of accidents.', 16, temperature=0.)[0]
      >>> # Output: "Je suis victime d'une série d'accidents."
  
      For onnx:
      >>> from transformers import T5Tokenizer
      >>> from onnxruntime import InferenceSession
      >>> from onnxt5 import GenerativeT5
      >>> decoder_sess = InferenceSession('~/t5-decoder-with-lm-head.onnx')
      >>> encoder_sess = InferenceSession('~/t5-encoder.onnx')
      >>> tokenizer = T5Tokenizer.from_pretrained(pretrained_model)
      >>> generative_t5 = GenerativeT5(encoder_sess, decoder_sess, tokenizer, onnx=True)
      >>> generative_t5('translate English to French: I was a victim of a series of accidents.', 16, temperature=0.)[0]
      >>> # Output: "Je suis victime d'une série d'accidents."
code: def __init__(
      self,
      encoder,
      decoder_with_lm_head,
      tokenizer,
      onnx=False,
      cuda=False,
  ):
      super().__init__()
      self.encoder = encoder
      self.decoder_with_lm_head = decoder_with_lm_head
      self.tokenizer = tokenizer
      self.onnx = onnx
      self.cuda = cuda
  
file_path: onnxt5/onnxt5/models.py
imports: import torch
  import torch.nn.functional
  from tqdm import trange
label_desc: Use image node_id 1 to create a new GenerativeT5 object from inherited base classes: torch.nn with example: obj = GenerativeT5(encoder, decoder_with_lm_head, tokenizer, onnx, cuda)