code: def test_fit_variables():
      """Test training a subset of the variables in a model."""
  
      class VarModel(torch.nn.Module):
          def __init__(self, **kwargs):
              super(VarModel, self).__init__(**kwargs)
              self.var1 = torch.nn.Parameter(torch.Tensor([0.5]))
              self.var2 = torch.nn.Parameter(torch.Tensor([0.5]))
  
          def forward(self, inputs):
              return [self.var1, self.var2]
  
      def loss(outputs, labels, weights):
          return (outputs[0] * outputs[1] - labels[0]) ** 2
  
      pytorch_model = VarModel()
      model = dc.models.TorchModel(
          pytorch_model, loss, learning_rate=0.02
      )
      x = np.ones((1, 1))
      vars = model.predict_on_batch(x)
      assert np.allclose(vars[0], 0.5)
      assert np.allclose(vars[1], 0.5)
      model.fit_generator([(x, x, x)] * 300)
      vars = model.predict_on_batch(x)
      assert np.allclose(vars[0], 1.0)
      assert np.allclose(vars[1], 1.0)
      model.fit_generator(
          [(x, 2 * x, x)] * 300, variables=[pytorch_model.var1]
      )
      vars = model.predict_on_batch(x)
      assert np.allclose(vars[0], 2.0)
      assert np.allclose(vars[1], 1.0)
      model.fit_generator(
          [(x, x, x)] * 300, variables=[pytorch_model.var2]
      )
      vars = model.predict_on_batch(x)
      assert np.allclose(vars[0], 2.0)
      assert np.allclose(vars[1], 0.5)
  
file_path: deepchem/deepchem/models/tests/test_torch_model.py
imports: import os
  import pytest
  import deepchem
  import numpy
  import math
  import unittest
label_desc: Use image node_id 12 for calling a global function with example usage: test_fit_variables() and returns: unknown, list