def testOneHotEncoding(self):
    """Tests one hot encoding of multiclass labels."""
    def graph_fn():
      labels = tf.constant([1, 4, 2], dtype=tf.int32)
      one_hot = preprocessor.one_hot_encoding(labels, num_classes=5)
      return one_hot
    one_hot = self.execute_cpu(graph_fn, [])
    self.assertAllEqual([0, 1, 1, 0, 1], one_hot)
Tests one hot encoding of multiclass labels.
inference_api/src/main/object_detection/core/preprocessor_test.py