code: def _perchannel(x, num_space):
      pos = np.zeros(shape=x.shape)
      for i in range(1, num_space):
          pos[x > float(i) / num_space] += 1
  
      onehot_rep = to_categorical(pos.reshape(-1), num_space)
  
      for i in reversed(list(range(1, num_space))):
          onehot_rep[:, i] += np.sum(onehot_rep[:, :i], axis=1)
  
      result = onehot_rep.reshape(list(x.shape) + [num_space])
  
      return result
  
imports: from builtins import range
  import logging
  import numpy
  from keras.utils import to_categorical
label_desc: Use image node_id 1 for calling a global function with example usage: _perchannel(x, num_space) and returns: result