def encode_value(self, values):
    """Encode values as tf.train.Feature."""
    if values is None:
      self._feature.Clear()
      # Note after Clear(), self._value no longer points to a submessage of
      # self._feature so we need to reset it.
      self._value = self._value_fn(self._feature)
    else:
      del self._value[:]

      # Scalar must be length 1 array.
      values = values if isinstance(values, (list, np.ndarray)) else [values]
      casted = self._cast_fn(values)
      self._value.extend(casted)
Encode values as tf.train.Feature.
tensorflow_transform/coders/example_proto_coder.py