'Decodes the given serialized TF-example.
Args:
serialized_example: a serialized TF-example tensor.
items: the list of items to decode. These must be a subset of the item
keys in self._items_to_handlers. If `items` is left as None, then all
of the items in self._items_to_handlers are decoded.
Returns:
the decoded items, a list of tensor.'

def decode(self, serialized_example, items=None):

    (context, sequence) = tf.parse_single_sequence_example(serialized_example, self._context_keys_to_features, self._sequence_keys_to_features)
    example = {}
    example.update(context)
    example.update(sequence)
    all_features = {}
    all_features.update(self._context_keys_to_features)
    all_features.update(self._sequence_keys_to_features)
    for (k, value) in all_features.items():
        if isinstance(value, tf.FixedLenFeature):
            example[k] = tf.reshape(example[k], value.shape)
    if (not items):
        items = self._items_to_handlers.keys()
    outputs = []
    for item in items:
        handler = self._items_to_handlers[item]
        keys_to_tensors = {key: example[key] for key in handler.keys}
        outputs.append(handler.tensors_to_item(keys_to_tensors))
    return outputs
