code: def test_checkpoint_saving_during_training(
      self, rae, trainer, training_configs
  ):
      #
      target_saving_epoch = training_configs.steps_saving
  
      dir_path = training_configs.output_dir
  
      model = deepcopy(trainer.model)
  
      trainer.train()
  
      training_dir = os.path.join(
          dir_path, f"RAE_L2_training_{trainer._training_signature}"
      )
      assert os.path.isdir(training_dir)
  
      checkpoint_dir = os.path.join(
          training_dir, f"checkpoint_epoch_{target_saving_epoch}"
      )
  
      assert os.path.isdir(checkpoint_dir)
  
      files_list = os.listdir(checkpoint_dir)
  
      # check files
      assert set(
          [
              "model.pt",
              "encoder_optimizer.pt",
              "decoder_optimizer.pt",
              "training_config.json",
          ]
      ).issubset(set(files_list))
  
      # check pickled custom decoder
      if not rae.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 rae.model_config.uses_default_encoder:
          assert "encoder.pkl" in files_list
  
      else:
          assert not "encoder.pkl" in files_list
  
      model_rec_state_dict = torch.load(
          os.path.join(checkpoint_dir, "model.pt")
      )["model_state_dict"]
  
      assert not all(
          [
              torch.equal(
                  model_rec_state_dict[key], model.state_dict()[key]
              )
              for key in model.state_dict().keys()
          ]
      )
  
imports: import os
  from copy import deepcopy
  import pytest
  import torch
  from torch.optim import Adam
  from pythae.customexception import BadInheritanceError
  from pythae.models import RAE_L2, AutoModel, RAE_L2_Config
  from pythae.models.base.base_utils import ModelOutput
  from pythae.pipelines import GenerationPipeline, TrainingPipeline
  from pythae.samplers import GaussianMixtureSamplerConfig, IAFSamplerConfig, MAFSamplerConfig, NormalSamplerConfig
  from pythae.trainers import BaseTrainerConfig, CoupledOptimizerTrainer, CoupledOptimizerTrainerConfig
  from tests.data.custom_architectures import Decoder_AE_Conv, Encoder_AE_Conv, NetBadInheritance
label_desc: Use image node_id 10 for calling the Test_RAE_L2_Training obj's underlying member method code with example usage: obj.test_checkpoint_saving_during_training(rae, trainer, training_configs) without return types