code: def test_save_load(init_rbm, affinity_matrix):
      # obtain the train/test set matrices
      Xtr, _ = affinity_matrix
  
      # initialize the model
      original_model = RBM(
          possible_ratings=np.setdiff1d(np.unique(Xtr), np.array([0])),
          visible_units=Xtr.shape[1],
          hidden_units=init_rbm["n_hidden"],
          training_epoch=init_rbm["epochs"],
          minibatch_size=init_rbm["minibatch"],
          keep_prob=init_rbm["keep_prob"],
          learning_rate=init_rbm["learning_rate"],
          init_stdv=init_rbm["init_stdv"],
          sampling_protocol=init_rbm["sampling_protocol"],
          display_epoch=init_rbm["display_epoch"],
      )
  
      # save the model
      original_model.save()
  
      # initialize another model
      saved_model = RBM(
          possible_ratings=np.setdiff1d(np.unique(Xtr), np.array([0])),
          visible_units=Xtr.shape[1],
          hidden_units=init_rbm["n_hidden"],
          training_epoch=init_rbm["epochs"],
          minibatch_size=init_rbm["minibatch"],
          keep_prob=init_rbm["keep_prob"],
          learning_rate=init_rbm["learning_rate"],
          init_stdv=init_rbm["init_stdv"],
          sampling_protocol=init_rbm["sampling_protocol"],
          display_epoch=init_rbm["display_epoch"],
      )
  
      # load the pretrained model
      saved_model.load()
  
      # list of unique rating values
      assert np.array_equal(
          saved_model.possible_ratings, original_model.possible_ratings
      )
      # number of visible units
      assert saved_model.n_visible == original_model.n_visible
      # number of hidden units
      assert saved_model.n_hidden == original_model.n_hidden
      # number of training epochs
      assert saved_model.epochs == original_model.epochs
      # minibatch size
      assert saved_model.minibatch == original_model.minibatch
      # keep probability for dropout regularization
      assert saved_model.keep == original_model.keep
      # learning rate
      assert saved_model.learning_rate == original_model.learning_rate
      # standard deviation used to initialize the weight matrix from a normal distribution
      assert saved_model.stdv == original_model.stdv
      # sampling protocol used to increase the number of steps in Gibbs sampling
      assert (
          saved_model.sampling_protocol
          == original_model.sampling_protocol
      )
      # number of epochs after which the rmse is displayed
      assert saved_model.display_epoch == original_model.display_epoch
  
imports: import pytest
  import numpy
label_desc: Use image node_id 5 for calling a global function with example usage: test_save_load(init_rbm, affinity_matrix) without return types