code: def test_load_freeze_unfreeze():
      np.random.seed(123)
      torch.manual_seed(10)
      n_samples = 60
      n_feat = 3
      d_hidden = 3
      n_layers = 1
      ft_tasks = 6
      pt_tasks = 6
  
      X_ft = np.random.rand(n_samples, n_feat)
      y_ft = np.random.rand(n_samples, ft_tasks).astype(np.float32)
      dataset_ft = dc.data.NumpyDataset(X_ft, y_ft)
  
      X_ft2 = np.random.rand(n_samples, n_feat)
      y_ft2 = np.zeros((n_samples, ft_tasks)).astype(np.float32)
      dataset_ft2 = dc.data.NumpyDataset(X_ft2, y_ft2)
  
      X_pt = np.random.rand(n_samples, n_feat)
      y_pt = np.random.rand(n_samples, pt_tasks).astype(np.float32)
      dataset_pt = dc.data.NumpyDataset(X_pt, y_pt)
  
      example_model = ExampleTorchModel(
          n_feat, d_hidden, n_layers, ft_tasks
      )
      example_pretrainer = ExamplePretrainer(example_model, pt_tasks)
  
      example_pretrainer.fit(dataset_pt, nb_epoch=1000)
  
      example_model.load_from_pretrained(
          model_dir=example_pretrainer.model_dir, components=["encoder"]
      )
  
      example_model.freeze_components(["encoder"])
  
      example_model.fit(dataset_ft, nb_epoch=100)
  
      # check that the first layer is still the same between the two models
      assert np.array_equal(
          example_pretrainer.components["encoder"][0]
          .weight.data.cpu()
          .numpy(),
          example_model.components["encoder"][0]
          .weight.data.cpu()
          .numpy(),
      )
  
      # check that the predictions are different because of the fine tuning
      assert not np.array_equal(
          np.round(
              np.squeeze(example_pretrainer.predict_on_batch(X_ft))
          ),
          np.round(np.squeeze(example_model.predict_on_batch(X_ft))),
      )
  
      example_model.unfreeze_components(["encoder"])
  
      example_model.fit(dataset_ft2, nb_epoch=100)
  
      # check that the first layer is different between the two models
      assert not np.array_equal(
          example_pretrainer.components["encoder"][0]
          .weight.data.cpu()
          .numpy(),
          example_model.components["encoder"][0]
          .weight.data.cpu()
          .numpy(),
      )
  
imports: import pytest
  import deepchem
  import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: test_load_freeze_unfreeze() without return types