code: def __init__(
      self,
      model: Union[PreTrainedModel, nn.Module] = None,
      args: TrainingArguments = None,
      data_collator: Optional[DataCollator] = None,
      train_dataset: Optional[Dataset] = None,
      eval_dataset: Optional[Dataset] = None,
      tokenizer: Optional[PreTrainedTokenizerBase] = None,
      model_init: Callable[[], PreTrainedModel] = None,
      compute_metrics: Optional[
          Callable[[EvalPrediction], Dict]
      ] = None,
      callbacks: Optional[List[TrainerCallback]] = None,
      adapter_names: Optional[List[List[str]]] = None,
      optimizers: Tuple[
          torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR
      ] = (None, None),
      preprocess_logits_for_metrics: Callable[
          [torch.Tensor, torch.Tensor], torch.Tensor
      ] = None,
  ):
      super().__init__(
          model,
          args,
          data_collator,
          train_dataset,
          eval_dataset,
          tokenizer=tokenizer,
          model_init=model_init,
          compute_metrics=compute_metrics,
          callbacks=[AdapterTrainerCallback(self)] + callbacks
          if callbacks
          else [AdapterTrainerCallback(self)],
          optimizers=optimizers,
          preprocess_logits_for_metrics=preprocess_logits_for_metrics,
      )
  
      if adapter_names is not None:
          self.model.set_active_adapters(adapter_names)
      # Set the defaults for loading/ saving model & adapters
      if isinstance(self.model, PreTrainedModel):
          model_frozen = getattr(
              self.model.base_model, "model_frozen", False
          )
      else:
          model_frozen = False
      if model_frozen and self.model.active_adapters:
          # Check if training AdapterFusion
          self.train_adapter_fusion = (
              isinstance(self.model.active_adapters, Fuse)
              or isinstance(
                  self.model.active_adapters, AdapterCompositionBlock
              )
              and any(
                  [
                      isinstance(child, Fuse)
                      for child in self.model.active_adapters.children
                  ]
              )
          )
      if self.model.active_adapters is None:
          raise ValueError(
              "Expected a model with an active adapter setup."
              "If you want to fully finetune the model use the Trainer class."
          )
      if (
          self.label_names is None or len(self.label_names) < 1
      ) and self.model.active_head is not None:
          all_label_names = set()
          for head in self.model._active_heads:
              all_label_names |= set(
                  self.model.heads[head].get_label_names()
              )
          self.label_names = list(all_label_names)
  
imports: import os
  import re
  from typing import Callable, Dict, List, Optional, Tuple, Union
  import torch
  from torch import nn
  from torch.utils.data.dataset import Dataset
  from transformers import PreTrainedModel, Seq2SeqTrainer, Trainer, __version__
  from transformers.configuration_utils import PretrainedConfig
  from transformers.data.data_collator import DataCollator
  from transformers.modeling_utils import unwrap_model
  from transformers.tokenization_utils_base import PreTrainedTokenizerBase
  from transformers.trainer_callback import TrainerCallback, TrainerControl, TrainerState
  from transformers.trainer_utils import EvalPrediction
  from transformers.training_args import TrainingArguments
  from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, is_sagemaker_mp_enabled, logging
  from .composition import AdapterCompositionBlock, Fuse
label_desc: Use image node_id 1 to create a new AdapterTrainer object from inherited base classes: Trainer with example: obj = AdapterTrainer(model, args, data_collator, train_dataset, eval_dataset, tokenizer, model_init, compute_metrics, callbacks, adapter_names, optimizers, preprocess_logits_for_metrics)