code: def test_fit_loss():
      """Test specifying a different loss function when calling fit()."""
  
      class VarModel(tf.keras.Model):
          def __init__(self, **kwargs):
              super(VarModel, self).__init__(**kwargs)
              self.var1 = tf.Variable([0.5])
              self.var2 = tf.Variable([0.5])
  
          def call(self, inputs, training=False):
              return [self.var1, self.var2]
  
      def loss1(outputs, labels, weights):
          return (outputs[0] * outputs[1] - labels[0]) ** 2
  
      def loss2(outputs, labels, weights):
          return (outputs[0] + outputs[1] - labels[0]) ** 2
  
      keras_model = VarModel()
      model = dc.models.KerasModel(
          keras_model, loss1, learning_rate=0.01
      )
      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, 3 * x, x)] * 300, loss=loss2)
      vars = model.predict_on_batch(x)
      assert np.allclose(vars[0] + vars[1], 3.0)
  
file_path: deepchem/deepchem/models/tests/test_kerasmodel.py
imports: import os
  import math
  import deepchem
  import numpy
  import unittest
  import pytest
label_desc: Use image node_id 13 for calling a global function with example usage: test_fit_loss() and returns: unknown, unknown, list