code: def test_smiles2vec_reload():
      """Test that smiles2vec models can be saved and reloaded."""
      dataset_file = os.path.join(
          os.path.dirname(__file__), "assets", "chembl_25_small.csv"
      )
      max_len = 250
      pad_len = 10
      max_seq_len = 20
      char_to_idx = create_char_to_idx(
          dataset_file, max_len=max_len, smiles_field="smiles"
      )
      feat = dc.feat.SmilesToSeq(
          char_to_idx=char_to_idx, max_len=max_len, pad_len=pad_len
      )
  
      n_tasks = 5
      data_points = 10
  
      loader = dc.data.CSVLoader(
          tasks=CHEMBL25_TASKS, smiles_field="smiles", featurizer=feat
      )
      dataset = loader.create_dataset(
          inputs=[dataset_file],
          shard_size=10000,
          data_dir=tempfile.mkdtemp(),
      )
      y = np.random.randint(0, 2, size=(data_points, n_tasks))
      w = np.ones(shape=(data_points, n_tasks))
      dataset = dc.data.NumpyDataset(
          dataset.X[:data_points, :max_seq_len],
          y,
          w,
          dataset.ids[:data_points],
      )
  
      _ = dc.metrics.Metric(
          dc.metrics.roc_auc_score, np.mean, mode="classification"
      )
  
      model_dir = tempfile.mkdtemp()
      model = dc.models.Smiles2Vec(
          char_to_idx=char_to_idx,
          max_seq_len=max_seq_len,
          use_conv=True,
          n_tasks=n_tasks,
          model_dir=model_dir,
          mode="classification",
      )
      model.fit(dataset, nb_epoch=3)
  
      # Reload Trained Model
      reloaded_model = dc.models.Smiles2Vec(
          char_to_idx=char_to_idx,
          max_seq_len=max_seq_len,
          use_conv=True,
          n_tasks=n_tasks,
          model_dir=model_dir,
          mode="classification",
      )
      reloaded_model.restore()
  
      # Check predictions match on original dataset
      origpred = model.predict(dataset)
      reloadpred = reloaded_model.predict(dataset)
      assert np.all(origpred == reloadpred)
  
imports: import os
  import pytest
  import tempfile
  import numpy
  import deepchem
  import scipy.io
  from flaky import flaky
  from sklearn.ensemble import RandomForestClassifier
  from deepchem.molnet.load_function.chembl25_datasets import CHEMBL25_TASKS
  from deepchem.feat import create_char_to_idx
label_desc: Use image node_id 19 for calling a global function with example usage: test_smiles2vec_reload() without return types