code: def test_sparse_categorical_crossentropy(self):
      import keras.backend as K
  
      y_a = np.array([0.12, 0.22, 0.30, 0.17, 0.19])
      # index starts from 1 in BigDL but starts from 0 in Keras
      y_b_bigdl = np.array([2])
      y_b_keras = np.array([1])
      kloss = objectives.sparse_categorical_crossentropy
      bloss = OptimConverter.to_bigdl_criterion(
          "sparse_categorical_crossentropy"
      )
      bigdl_output = bloss.forward(y_a, y_b_bigdl)
      keras_output = np.mean(
          K.eval(kloss(K.variable(y_b_keras), K.variable(y_a)))
      )
      np.testing.assert_allclose(bigdl_output, keras_output)
  
file_path: BigDL/python/dllib/test/bigdl/nn/test_loss.py
imports: from __future__ import print_function
  import numpy
  import pytest
  from keras import objectives
  from bigdl.dllib.nn.keras.optimization import OptimConverter
  from test.bigdl.test_utils import BigDLTestCase
label_desc: Use image node_id 7 for calling the TestLoss obj's underlying member method code with example usage: obj.test_sparse_categorical_crossentropy() without return types