code: def ref_one_hot(x, shape):
      num_classes = shape
      result = np.zeros((x.shape[0],) + shape)
      for i in range(x.shape[0]):
          class_idxs = []
          valid_class = True
          for class_idx, num_classes in zip(x[i], shape):
              if class_idx < 0:
                  class_idx += num_classes
              if class_idx < 0 or num_classes <= class_idx:
                  valid_class = False
                  break
              class_idxs.append(class_idx)
          idx = (i,) + tuple(class_idxs)
          if valid_class:
              result[idx] = 1
      return result
  
file_path: nnabla/python/test/function/test_one_hot.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_one_hot(x, shape) and returns: result