code: def to_categorical(y, nb_classes, num_classes=None):
      """
      Converts a class vector (integers) to binary class matrix.
      This is adapted from the Keras function with the same name.
      :param y: class vector to be converted into a matrix
                (integers from 0 to nb_classes).
      :param nb_classes: nb_classes: total number of classes.
      :param num_classses: depricated version of nb_classes
      :return: A binary matrix representation of the input.
      """
      if num_classes is not None:
          if nb_classes is not None:
              raise ValueError(
                  "Should not specify both nb_classes and its deprecated "
                  "alias, num_classes"
              )
          warnings.warn(
              "`num_classes` is deprecated. Switch to `nb_classes`."
              " `num_classes` may be removed on or after 2019-04-23."
          )
          nb_classes = num_classes
          del num_classes
      y = np.array(y, dtype="int").ravel()
      n = y.shape[0]
      categorical = np.zeros((n, nb_classes))
      categorical[np.arange(n), y] = 1
      return categorical
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  from collections import OrderedDict
  import warnings
  import logging
  import os
  import re
  import subprocess
  import numpy
  from six.moves import xrange
label_desc: Use image node_id 3 for calling a global function with example usage: to_categorical(y, nb_classes, num_classes) and returns: categorical