code: def ref_confusion_matrix(x, l, axis):
      orig_x = x.copy()
      x = np.rollaxis(x, axis, x.ndim).reshape(-1, x.shape[axis])
      ll = np.rollaxis(l, axis, x.ndim).flatten()
      y = np.zeros((orig_x.shape[axis], orig_x.shape[axis]), int)
      for x_, ll_ in zip(x, ll):
          index = -1
          for i, x__ in enumerate(x_):
              if x__ >= x_[index]:
                  index = i
          y[ll_][index] += 1
      return y
  
file_path: nnabla/python/test/function/test_confusion_matrix.py
imports: import pytest
  import numpy
  import nnabla
  import nnabla.functions
  from nbla_test_utils import list_context
  from nnabla.testing import assert_allclose
label_desc: Use image node_id 1 for calling a global function with example usage: ref_confusion_matrix(x, l, axis) and returns: y