code: def test_grover_model_save_restore(tmpdir, task):
      # arranging for tests
      from deepchem.models.torch_models.grover import GroverModel
      from deepchem.feat.vocabulary_builders import (
          GroverAtomVocabularyBuilder,
          GroverBondVocabularyBuilder,
      )
  
      atom_vocabulary = GroverAtomVocabularyBuilder(max_size=100)
      bond_vocabulary = GroverBondVocabularyBuilder(max_size=100)
  
      model_config = {
          "node_fdim": 151,
          "edge_fdim": 165,
          "atom_vocab": atom_vocabulary,
          "bond_vocab": bond_vocabulary,
          "features_dim": 2048,
          "hidden_size": 128,
          "functional_group_size": 85,
          "mode": "regression",
          "model_dir": tmpdir,
          "task": task,
      }
  
      old_model = GroverModel(
          **model_config, device=torch.device("cpu")
      )
      old_model._ensure_built()
      old_model.save_checkpoint()
  
      new_model = GroverModel(
          **model_config, device=torch.device("cpu")
      )
      new_model._ensure_built()
      # checking weights don't match before restore
      old_state = old_model.model.state_dict()
      new_state = new_model.model.state_dict()
  
      for key in new_state.keys():
          # norm layers and cached zero vectors have constant weights
          if "norm" not in key and "zero" not in key:
              assert not torch.allclose(old_state[key], new_state[key])
  
      # restoring model
      new_model.restore()
  
      # checking matching of weights after restore
      old_state = old_model.model.state_dict()
      new_state = new_model.model.state_dict()
  
      for key in new_state.keys():
          assert torch.allclose(old_state[key], new_state[key])
  
file_path: deepchem/deepchem/models/torch_models/tests/test_grover.py
imports: import os
  import pytest
  import numpy
  import deepchem
label_desc: Use image node_id 8 for calling a global function with example usage: test_grover_model_save_restore(tmpdir, task) without return types