code: def compareLossWithKeras(
      self, kkloss_func, zloss, shape, sizeAverageKerasLoss=True
  ):
      y_pred = klayers.Input(shape=shape[1:])
      y_true = klayers.Input(shape=shape[1:])
  
      batch = shape[0]
  
      kkloss = kkloss_func(y_true, y_pred)
      y_true_value = np.random.uniform(0, 1, shape)
      y_pred_value = np.random.uniform(0, 1, shape)
  
      k_grad_y_pred = KK.get_session().run(
          KK.gradients(kkloss, y_pred),
          feed_dict={y_true: y_true_value, y_pred: y_pred_value},
      )[0]
      k_output = KK.get_session().run(
          kkloss, feed_dict={y_true: y_true_value, y_pred: y_pred_value}
      )
      z_output = zloss.forward(y_true_value, y_pred_value)
      z_grad_y_pred = zloss.backward(y_true_value, y_pred_value)
  
      assert z_output == pytest.approx(np.mean(k_output), 1e-5, 1e-5)
      if sizeAverageKerasLoss:
          self.assert_allclose(k_grad_y_pred / batch, z_grad_y_pred)
      else:
          self.assert_allclose(k_grad_y_pred, z_grad_y_pred)
  
file_path: analytics-zoo/pyzoo/test/zoo/pipeline/autograd/test_loss.py
imports: import keras.backend
  import keras.layers
  import keras.objectives
  import pytest
  from test.zoo.pipeline.utils.test_utils import ZooTestCase
  from zoo.pipeline.api.autograd import *
  from zoo.pipeline.api.keras.models import *
  from zoo.pipeline.api.keras.layers import *
label_desc: Use image node_id 1 for calling the TestLoss obj's underlying member method code with example usage: obj.compareLossWithKeras(kkloss_func, zloss, shape, sizeAverageKerasLoss) without return types