def decode_example(self, serialized_example):
    """Return a dict of Tensors from a serialized tensorflow.Example."""
    data_fields, data_items_to_decoders = self.example_reading_spec()
    # Necessary to rejoin examples in the correct order with the Cloud ML Engine
    # batch prediction API.
    data_fields["batch_prediction_key"] = tf.FixedLenFeature([1], tf.int64, 0)

    if getattr(self._hparams, "sampling_method", "") == "random_per_example":
      data_fields["sampling_temp"] = tf.FixedLenFeature(
          [1], tf.float32, getattr(self._hparams, "sampling_temp", 1.0))
      data_fields["sampling_keep_top_k"] = tf.FixedLenFeature(
          [1], tf.int64, getattr(self._hparams, "sampling_keep_top_k", -1))

    if data_items_to_decoders is None:
      data_items_to_decoders = {}
      for field in data_fields:
        if data_fields[field].dtype is tf.string:
          default_value = b""
        else:
          default_value = 0
        data_items_to_decoders[field] = contrib.slim().tfexample_decoder.Tensor(
            field, default_value=default_value)

    decoder = contrib.slim().tfexample_decoder.TFExampleDecoder(
        data_fields, data_items_to_decoders)

    decode_items = list(sorted(data_items_to_decoders))
    decoded = decoder.decode(serialized_example, items=decode_items)
    return dict(zip(decode_items, decoded))
Return a dict of Tensors from a serialized tensorflow.Example.
tensor2tensor/data_generators/problem.py