code: def _save(self, output_dir: Optional[str] = None, state_dict=None):
      # If we are executing this function, we are the process zero, so we don't check for that.
      output_dir = (
          output_dir if output_dir is not None else self.args.output_dir
      )
      os.makedirs(output_dir, exist_ok=True)
      logger.info(f"Saving model checkpoint to {output_dir}")
      # Save a trained model and configuration using `save_pretrained()`.
      # They can then be reloaded using `from_pretrained()`
      if not isinstance(self.model, PreTrainedModel):
          if isinstance(unwrap_model(self.model), PreTrainedModel):
              if state_dict is None:
                  state_dict = self.model.state_dict()
              unwrap_model(self.model).save_pretrained(
                  output_dir, state_dict=state_dict
              )
          else:
              logger.info(
                  "Trainer.model is not a `PreTrainedModel`, only saving its state dict."
              )
              if state_dict is None:
                  state_dict = self.model.state_dict()
              torch.save(
                  state_dict, os.path.join(output_dir, WEIGHTS_NAME)
              )
      else:
          self.model.save_all_adapters(output_dir)
          if self.train_adapter_fusion:
              self.model.save_all_adapter_fusions(output_dir)
          if hasattr(self.model, "heads"):
              self.model.save_all_heads(output_dir)
      if self.tokenizer is not None:
          self.tokenizer.save_pretrained(output_dir)
  
      # Good practice: save your training arguments together with the trained model
      torch.save(
          self.args, os.path.join(output_dir, "training_args.bin")
      )
  
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 3 for calling the AdapterTrainer obj's underlying member method code with example usage: obj._save(output_dir, state_dict) without return types