code: def test_final_model_saving(self, vae, trainer, training_configs):
      dir_path = training_configs.output_dir
  
      trainer.train()
  
      model = deepcopy(trainer._best_model)
  
      training_dir = os.path.join(
          dir_path, f"VAE_LinNF_training_{trainer._training_signature}"
      )
      assert os.path.isdir(training_dir)
  
      final_dir = os.path.join(training_dir, f"final_model")
      assert os.path.isdir(final_dir)
  
      files_list = os.listdir(final_dir)
  
      assert set(
          ["model.pt", "model_config.json", "training_config.json"]
      ).issubset(set(files_list))
  
      # check pickled custom decoder
      if not vae.model_config.uses_default_decoder:
          assert "decoder.pkl" in files_list
  
      else:
          assert not "decoder.pkl" in files_list
  
      # check pickled custom encoder
      if not vae.model_config.uses_default_encoder:
          assert "encoder.pkl" in files_list
  
      else:
          assert not "encoder.pkl" in files_list
  
      # check reload full model
      model_rec = AutoModel.load_from_folder(os.path.join(final_dir))
  
      assert all(
          [
              torch.equal(
                  model_rec.state_dict()[key].cpu(),
                  model.state_dict()[key].cpu(),
              )
              for key in model.state_dict().keys()
          ]
      )
  
      assert type(model_rec.encoder.cpu()) == type(model.encoder.cpu())
      assert type(model_rec.decoder.cpu()) == type(model.decoder.cpu())
  
imports: import os
  from copy import deepcopy
  import pytest
  import torch
  from pydantic import ValidationError
  from pythae.customexception import BadInheritanceError
  from pythae.models import AutoModel, VAE_LinNF, VAE_LinNF_Config
  from pythae.models.base.base_utils import ModelOutput
  from pythae.pipelines import GenerationPipeline, TrainingPipeline
  from pythae.samplers import GaussianMixtureSamplerConfig, IAFSamplerConfig, MAFSamplerConfig, NormalSamplerConfig, TwoStageVAESamplerConfig
  from pythae.trainers import BaseTrainer, BaseTrainerConfig
  from tests.data.custom_architectures import Decoder_AE_Conv, Encoder_VAE_Conv, NetBadInheritance
label_desc: Use image node_id 11 for calling the Test_VAE_Training obj's underlying member method code with example usage: obj.test_final_model_saving(vae, trainer, training_configs) without return types