class_docstr: Base class to perform model training.
  
  Args:
      model (BaseAE): A instance of :class:`~pythae.models.BaseAE` to train
  
      train_dataset (BaseDataset): The training dataset of type
          :class:`~pythae.data.dataset.BaseDataset`
  
      eval_dataset (BaseDataset): The evaluation dataset of type
          :class:`~pythae.data.dataset.BaseDataset`
  
      training_config (BaseTrainerConfig): The training arguments summarizing the main
          parameters used for training. If None, a basic training instance of
          :class:`BaseTrainerConfig` is used. Default: None.
  
      callbacks (List[~pythae.trainers.training_callbacks.TrainingCallbacks]):
          A list of callbacks to use during training.
docstr: This method saves the final model along with the config files
  
  Args:
      model (BaseAE): The model to be saved
      dir_path (str): The folder where the model and config files should be saved
docstr_tok: ["This","method","saves","the","final","model","along","with","the","config","files","Args",":","model","(","BaseAE",")",":","The","model","to","be","saved","dir_path","(","str",")",":","The","folder","where","the","model","and","config","files","should","be","saved"]
code: def save_model(self, model: BaseAE, dir_path: str):
      """This method saves the final model along with the config files
  
      Args:
          model (BaseAE): The model to be saved
          dir_path (str): The folder where the model and config files should be saved
      """
  
      if not os.path.exists(dir_path):
          os.makedirs(dir_path)
  
      # save model
      if self.distributed:
          model.module.save(dir_path)
  
      else:
          model.save(dir_path)
  
      # save training config
      self.training_config.save_json(dir_path, "training_config")
  
      self.callback_handler.on_save(self.training_config)
  
imports: import contextlib
  import datetime
  import logging
  import os
  from copy import deepcopy
  from typing import Any, Dict, List, Optional, Union
  import torch
  import torch.distributed
  import torch.optim
  import torch.optim.lr_scheduler
  from torch.nn.parallel import DistributedDataParallel
  from torch.utils.data import DataLoader, Dataset
  from torch.utils.data.distributed import DistributedSampler
  from ...customexception import ModelError
  from ...data.datasets import BaseDataset, collate_dataset_output
  from ...models import BaseAE
  from ..trainer_utils import set_seed
  from ..training_callbacks import CallbackHandler, MetricConsolePrinterCallback, ProgressBarCallback, TrainingCallback
  from .base_training_config import BaseTrainerConfig
label_desc: Use image node_id 20 for calling the BaseTrainer obj's underlying member method code with example usage: obj.save_model(model, dir_path) without return types