class_docstr: A seq2seq model with a value head in addition to the language model head.
  This class inherits from `~trl.PreTrainedModelWrapper` and wraps a
  `transformers.PreTrainedModel` class. The wrapper class supports classic functions
  such as `from_pretrained` and `push_to_hub` and also provides some additional
  functionalities such as `generate`.
  
  Args:
      pretrained_model (`transformers.PreTrainedModel`):
          The model to wrap. It should be a causal language model such as GPT2.
          or any model mapped inside the `AutoModelForSeq2SeqLM` class.
      kwargs:
          Additional keyword arguments passed along to the `ValueHead` class.
class_docstr_tok: ["A","seq2seq","model","with","a","value","head","in","addition","to","the","language","model","head",".","This","class","inherits","from","`","~trl.PreTrainedModelWrapper","`","and","wraps","a","`","transformers.PreTrainedModel","`","class",".","The","wrapper","class","supports","classic","functions","such","as","`","from_pretrained","`","and","`","push_to_hub","`","and","also","provides","some","additional","functionalities","such","as","`","generate","`",".","Args",":","pretrained_model","(","`","transformers.PreTrainedModel","`",")",":","The","model","to","wrap",".","It","should","be","a","causal","language","model","such","as","GPT2",".","or","any","model","mapped","inside","the","`","AutoModelForSeq2SeqLM","`","class",".","kwargs",":","Additional","keyword","arguments","passed","along","to","the","`","ValueHead","`","class","."]
code: def forward(
      self,
      input_ids=None,
      past_key_values=None,
      attention_mask=None,
      **kwargs,
  ):
      kwargs["past_key_values"] = past_key_values
      if (
          self.is_peft_model
          and self.pretrained_model.active_peft_config.peft_type
          == "PREFIX_TUNING"
      ):
          kwargs.pop("past_key_values")
  
      base_model_output = self.pretrained_model(
          input_ids=input_ids,
          attention_mask=attention_mask,
          output_hidden_states=True,  # We force the model to output hidden states
          **kwargs,
      )
  
      last_hidden_state = base_model_output.decoder_hidden_states[-1]
      lm_logits = base_model_output.logits
      loss = base_model_output.loss
  
      value = self.v_head(last_hidden_state).squeeze(-1)
  
      # force upcast in fp32 if logits are in half-precision
      if lm_logits.dtype != torch.float32:
          lm_logits = lm_logits.float()
  
      return (lm_logits, loss, value)
  
imports: import torch
  import torch.nn
  from transformers import AutoModelForCausalLM, AutoModelForSeq2SeqLM
  from .modeling_base import PreTrainedModelWrapper
label_desc: Use image node_id 7 for calling the AutoModelForSeq2SeqLMWithValueHead obj's underlying member method code with example usage: obj.forward(input_ids, past_key_values, attention_mask) and returns: lm_logits,  loss,  value