class_docstr: An autoregressive 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`, `push_to_hub` and `generate`. To call a method of the wrapped
  model, simply manipulate the `pretrained_model` attribute of this class.
  
  Class attributes:
      - **transformers_parent_class** (`transformers.PreTrainedModel`) -- The parent class of the wrapped model. This
          should be set to `transformers.AutoModelForCausalLM` for this class.
      - **lm_head_namings** (`tuple`) -- A tuple of strings that are used to identify the language model head of the
          wrapped model. This is set to `("lm_head", "embed_out")` for this class but can be changed for other models
          in the future
      - **supported_args** (`tuple`) -- A tuple of strings that are used to identify the arguments that are supported
          by the `ValueHead` class. Currently, the supported args are:
          - **summary_dropout_prob** (`float`, `optional`, defaults to `None`) -- The dropout probability for the
              `ValueHead` class.
          - **v_head_initializer_range** (`float`, `optional`, defaults to `0.2`) -- The initializer range for the
              `ValueHead` if a specific initialization strategy is selected.
          - **v_head_init_strategy** (`str`, `optional`, defaults to `None`) -- The initialization strategy for the
              `ValueHead`. Currently, the supported strategies are:
              - **`None`** -- Initializes the weights of the `ValueHead` with a random distribution. This is the default
                  strategy.
              - **"normal"** -- Initializes the weights of the `ValueHead` with a normal distribution.
class_docstr_tok: ["An","autoregressive","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","`",",","`","push_to_hub","`","and","`","generate","`",".","To","call","a","method","of","the","wrapped","model",",","simply","manipulate","the","`","pretrained_model","`","attribute","of","this","class",".","Class","attributes",":","-","*","*","transformers_parent_class","*","*","(","`","transformers.PreTrainedModel","`",")","--","The","parent","class","of","the","wrapped","model",".","This","should","be","set","to","`","transformers.AutoModelForCausalLM","`","for","this","class",".","-","*","*","lm_head_namings","*","*","(","`","tuple","`",")","--","A","tuple","of","strings","that","are","used","to","identify","the","language","model","head","of","the","wrapped","model",".","This","is","set","to","`","(","``","lm_head","''",",","``","embed_out","''",")","`","for","this","class","but","can","be","changed","for","other","models","in","the","future","-","*","*","supported_args","*","*","(","`","tuple","`",")","--","A","tuple","of","strings","that","are","used","to","identify","the","arguments","that","are","supported","by","the","`","ValueHead","`","class",".","Currently",",","the","supported","args","are",":","-","*","*","summary_dropout_prob","*","*","(","`","float","`",",","`","optional","`",",","defaults","to","`","None","`",")","--","The","dropout","probability","for","the","`","ValueHead","`","class",".","-","*","*","v_head_initializer_range","*","*","(","`","float","`",",","`","optional","`",",","defaults","to","`","0.2","`",")","--","The","initializer","range","for","the","`","ValueHead","`","if","a","specific","initialization","strategy","is","selected",".","-","*","*","v_head_init_strategy","*","*","(","`","str","`",",","`","optional","`",",","defaults","to","`","None","`",")","--","The","initialization","strategy","for","the","`","ValueHead","`",".","Currently",",","the","supported","strategies","are",":","-","*","*","`","None","`","*","*","--","Initializes","the","weights","of","the","`","ValueHead","`","with","a","random","distribution",".","This","is","the","default","strategy",".","-","*","*","''","normal","''","*","*","--","Initializes","the","weights","of","the","`","ValueHead","`","with","a","normal","distribution","."]
docstr: Initializes the model.
  
  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 `AutoModelForCausalLM` class.
      kwargs (`dict`, `optional`):
          Additional keyword arguments, that are passed to the `ValueHead` class.
docstr_tok: ["Initializes","the","model",".","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","`","AutoModelForCausalLM","`","class",".","kwargs","(","`","dict","`",",","`","optional","`",")",":","Additional","keyword","arguments",",","that","are","passed","to","the","`","ValueHead","`","class","."]
code: def __init__(self, pretrained_model, **kwargs):
      r"""
      Initializes the model.
  
      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 `AutoModelForCausalLM` class.
          kwargs (`dict`, `optional`):
              Additional keyword arguments, that are passed to the `ValueHead` class.
      """
      super().__init__(pretrained_model, **kwargs)
      v_head_kwargs, _, _ = self._split_kwargs(kwargs)
  
      if not any(
          hasattr(self.pretrained_model, attribute)
          for attribute in self.lm_head_namings
      ):
          raise ValueError(
              "The model does not have a language model head, please use a model that has one."
          )
  
      self.v_head = ValueHead(
          self.pretrained_model.config, **v_head_kwargs
      )
  
      self._init_weights(**v_head_kwargs)
  
imports: import torch
  import torch.nn
  from transformers import AutoModelForCausalLM, AutoModelForSeq2SeqLM
  from .modeling_base import PreTrainedModelWrapper
label_desc: Use image node_id 1 to create a new AutoModelForCausalLMWithValueHead object from inherited base classes: PreTrainedModelWrapper with example: obj = AutoModelForCausalLMWithValueHead(pretrained_model)