code: def test_ce():
      metric = mx.gluon.metric.create("ce")
      pred = mx.np.array([[0.2, 0.3, 0.5], [0.6, 0.1, 0.3]])
      label = mx.np.array([2, 1])
      metric.update([label], [pred])
      _, loss = metric.get()
      expected_loss = (
          -(np.log(pred[0][2].item()) + np.log(pred[1][1].item())) / 2
      )
      np.testing.assert_almost_equal(loss, expected_loss)
      metric = mx.gluon.metric.create("ce", from_logits=True)
      pred = mx.np.log(pred)
      metric.update([label], [pred])
      _, loss = metric.get()
      np.testing.assert_almost_equal(loss, expected_loss)
  
imports: import mxnet
  from mxnet.test_utils import use_np
  import numpy
  import scipy
  from scipy.stats import pearsonr
  import json
  import math
  from common import xfail_when_nonstandard_decimal_separator
  from copy import deepcopy
label_desc: Use image node_id 3 for calling a global function with example usage: test_ce() without return types