code: def to_categorical(y, num_classes):
      y = np.array(y, dtype="int")
      n = y.shape[0]
      categorical = np.zeros((n, num_classes))
      for i in range(0, n):
          categorical[i, y[i]] = 1
          categorical = categorical.astype(np.float32)
      return categorical
  
imports: from singa import singa_wrap
  from singa import autograd
  from singa import tensor
  from singa import device
  from singa import opt
  from PIL import Image
  import numpy
  import os
  import sys
  import time
label_desc: Use image node_id 9 for calling a global function with example usage: to_categorical(y, num_classes) and returns: categorical