class_docstr: creates a T5 model using onnx sessions (encode, decoder & init_decoder)
class_docstr_tok: ["creates","a","T5","model","using","onnx","sessions","(","encode",",","decoder","&","init_decoder",")"]
code: def forward(
      self,
      input_ids=None,
      attention_mask=None,
      decoder_input_ids=None,
      decoder_attention_mask=None,
      head_mask=None,
      decoder_head_mask=None,
      cross_attn_head_mask=None,
      encoder_outputs=None,
      past_key_values=None,
      inputs_embeds=None,
      decoder_inputs_embeds=None,
      labels=None,
      use_cache=None,
      output_attentions=None,
      output_hidden_states=None,
      return_dict=None,
  ):
      if encoder_outputs is None:
          # Convert encoder inputs in embeddings if needed
          encoder_outputs = self.encoder(
              input_ids=input_ids, attention_mask=attention_mask
          )
  
      encoder_hidden_states = encoder_outputs[0]
  
      if past_key_values is not None:
          if decoder_input_ids is not None:
              decoder_input_ids = decoder_input_ids[:, -1:]
          if decoder_inputs_embeds is not None:
              decoder_inputs_embeds = decoder_inputs_embeds[:, -1:]
  
      if past_key_values is None:
          # runs only for the first time:
          init_onnx_outputs = self.decoder_init(
              decoder_input_ids, attention_mask, encoder_hidden_states
          )
  
          logits, past_key_values = init_onnx_outputs
  
      else:
          onnx_outputs = self.decoder(
              decoder_input_ids,
              attention_mask,
              encoder_hidden_states,
              past_key_values,
          )
  
          logits, past_key_values = onnx_outputs
  
      return Seq2SeqLMOutput(
          logits=logits, past_key_values=past_key_values
      )
  
imports: from .huggingface_utils import get_auth_token
  from .ort_settings import get_onnx_runtime_sessions
  from .onnx_exporter import generate_onnx_representation, quantize, get_model_paths, saved_models_path
  from pathlib import Path
  from transformers import AutoConfig, MT5Config, T5ForConditionalGeneration
  from transformers.modeling_outputs import Seq2SeqLMOutput, BaseModelOutput
  import torch
  import functools
  import operator
label_desc: Use image node_id 2 for calling the OnnxT5 obj's underlying member method code with example usage: obj.forward(input_ids, attention_mask, decoder_input_ids, decoder_attention_mask, head_mask, decoder_head_mask, cross_attn_head_mask, encoder_outputs, past_key_values, inputs_embeds, decoder_inputs_embeds, labels, use_cache, output_attentions, output_hidden_states, return_dict) and returns: Seq2SeqLMOutput