code: def test_save_load_statedict(
      regression_data,
      model_config_class,
      continuous_cols,
      categorical_cols,
      custom_metrics,
      custom_loss,
      custom_optimizer,
      tmpdir,
  ):
      (train, test, target) = regression_data
      data_config = DataConfig(
          target=target,
          continuous_cols=continuous_cols,
          categorical_cols=categorical_cols,
      )
      model_config_class, model_config_params = model_config_class
      model_config_params["task"] = "regression"
      model_config = model_config_class(**model_config_params)
      trainer_config = TrainerConfig(
          max_epochs=3,
          checkpoints=None,
          early_stopping=None,
          accelerator="cpu",
          fast_dev_run=True,
      )
      optimizer_config = OptimizerConfig()
  
      tabular_model = TabularModel(
          data_config=data_config,
          model_config=model_config,
          optimizer_config=optimizer_config,
          trainer_config=trainer_config,
      )
      tabular_model.fit(
          train=train,
          metrics=custom_metrics,
          metrics_prob_inputs=None
          if custom_metrics is None
          else [False],
          loss=custom_loss,
          optimizer=custom_optimizer,
          optimizer_params={},
      )
  
      result_1 = tabular_model.evaluate(test)
      # sv_dir = tmpdir/"save_model"
      # sv_dir.mkdir(exist_ok=True, parents=True)
      sv_dir = tmpdir.mkdir("saved_model")
      tabular_model.save_weights(str(sv_dir / "weights.pt"))
      new_mdl = TabularModel(
          data_config=data_config,
          model_config=model_config,
          optimizer_config=optimizer_config,
          trainer_config=trainer_config,
          model_state_dict_path=str(sv_dir / "weights.pt"),
      )
      datamodule = new_mdl.prepare_dataloader(train)
      model = new_mdl.prepare_model(
          datamodule,
          metrics=custom_metrics,
          metrics_prob_inputs=None
          if custom_metrics is None
          else [False],
          loss=custom_loss,
          optimizer=custom_optimizer,
          optimizer_params={},
      )
      new_mdl._prepare_for_training(model, datamodule)
      result_2 = new_mdl.evaluate(test)
      assert (
          result_1[0][f"test_{tabular_model.model.hparams.metrics[0]}"]
          == result_2[0][f"test_{new_mdl.model.hparams.metrics[0]}"]
      )
  
imports: import copy
  import os
  import numpy
  import pytest
  import torch
  from pytorch_tabular import TabularModel, TabularModelTuner, model_sweep
  from pytorch_tabular.config import DataConfig, OptimizerConfig, TrainerConfig
  from pytorch_tabular.config.config import SSLModelConfig
  from pytorch_tabular.feature_extractor import DeepFeatureExtractor
  from pytorch_tabular.models import AutoIntConfig, CategoryEmbeddingModelConfig, FTTransformerConfig, GANDALFConfig, GatedAdditiveTreeEnsembleConfig, NodeConfig, TabNetModelConfig
  from pytorch_tabular.ssl_models import DenoisingAutoEncoderConfig
  from scipy.stats import randint, uniform
  from sklearn.metrics import accuracy_score, r2_score
  from sklearn.model_selection import KFold
label_desc: Use image node_id 5 for calling a global function with example usage: test_save_load_statedict(regression_data, model_config_class, continuous_cols, categorical_cols, custom_metrics, custom_loss, custom_optimizer, tmpdir) without return types