code: def test_custom_encoder_model_saving(
      self, tmpdir, model_configs, custom_encoder
  ):
      tmpdir.mkdir("dummy_folder")
      dir_path = dir_path = os.path.join(tmpdir, "dummy_folder")
  
      model = IWAE(model_configs, encoder=custom_encoder)
  
      model.state_dict()["encoder.layers.0.0.weight"][0] = 0
  
      model.save(dir_path=dir_path)
  
      assert set(os.listdir(dir_path)) == set(
          [
              "model_config.json",
              "model.pt",
              "encoder.pkl",
              "environment.json",
          ]
      )
  
      # reload model
      model_rec = AutoModel.load_from_folder(dir_path)
  
      # check configs are the same
      assert (
          model_rec.model_config.__dict__ == model.model_config.__dict__
      )
  
      assert 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 pythae.customexception import BadInheritanceError
  from pythae.models import IWAE, AutoModel, IWAEConfig
  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 2 for calling the Test_Model_Saving obj's underlying member method code with example usage: obj.test_custom_encoder_model_saving(tmpdir, model_configs, custom_encoder) without return types