docstr: Initializes a model.
docstr_tok: ["Initializes","a","model","."]
code: def init_model(self, new: bool = False) -> None:
      """
      Initializes a model.
      """
      from transformers import (
          AutoModelForCausalLM,
          AutoModelForSequenceClassification,
          AutoTokenizer,
          PreTrainedModel,
          PreTrainedTokenizer,
      )
      from trl import (
          AutoModelForCausalLMWithValueHead,
          create_reference_model,
      )
  
      if isinstance(
          self._task, (TrainingTaskForSFT, TrainingTaskForDPO)
      ):
          auto_model_class = AutoModelForCausalLM
      elif isinstance(self._task, TrainingTaskForPPO):
          auto_model_class = AutoModelForCausalLMWithValueHead
      elif isinstance(self._task, TrainingTaskForRM):
          auto_model_class = AutoModelForSequenceClassification
  
      if self.trainer_model is None:
          self.trainer_model: PreTrainedModel = (
              auto_model_class.from_pretrained(self._model)
          )
      if self.trainer_tokenizer is None:
          self.trainer_tokenizer: PreTrainedTokenizer = (
              AutoTokenizer.from_pretrained(
                  self.trainer_model.config.name_or_path
              )
          )
          self.trainer_tokenizer.pad_token_id = (
              self.trainer_tokenizer.eos_token_id
          )
      self.trainer_model.config.pad_token_id = (
          self.trainer_tokenizer.pad_token_id
      )
  
      if isinstance(
          self._task, (TrainingTaskForPPO, TrainingTaskForDPO)
      ):
          self.trainer_ref_model: PreTrainedModel = (
              create_reference_model(self.trainer_model)
          )
      if new:
          self.trainer_model.to(self.device)
  
file_path: argilla/src/argilla/client/feedback/training/frameworks/trl.py
imports: import logging
  from typing import TYPE_CHECKING, Dict, List, Optional, Union
  from argilla.client.feedback.training.base import ArgillaTrainerSkeleton
  from argilla.client.feedback.training.schemas.base import TrainingTaskForDPO, TrainingTaskForPPO, TrainingTaskForRM, TrainingTaskForSFT
  from argilla.training.utils import filter_allowed_args
  from argilla.utils.dependency import require_dependencies, requires_dependencies
label_desc: Use image node_id 3 for calling the ArgillaTRLTrainer obj's underlying member method code with example usage: obj.init_model(new) without return types