def encode_map_fn(example):
      """Read example from tfds and constructed named tensor inputs."""
      tensors = tf.py_function(
          encode,
          inp=[
              example['claim_text'], example['evidence_text'],
              example['claim_label'], example['evidence_label'],
              example['metadata'], example['wikipedia_url'],
              example['sentence_id']
          ],
          Tout=(
              tf.string,
              tf.int32,
              tf.int32,
              tf.int32,
              tf.string,
              tf.int32,
              tf.int32,
              tf.int32,
              tf.int64,
              tf.int64,
              tf.string,
          ))
      # Keras expects (x, y), where x can be a dictionary.
      x = {
          'claim_text_tokens': tensors[0],
          'claim_text_word_ids': tensors[1],
          'claim_text_mask': tensors[2],
          'claim_text_segment_ids': tensors[3],
          'evidence_text_tokens': tensors[4],
          'evidence_text_word_ids': tensors[5],
          'evidence_text_mask': tensors[6],
          'evidence_text_segment_ids': tensors[7],
          'claim_label': tensors[8],
          'evidence_label': tensors[9],
          'metadata': tensors[10]
      }
      # Order matters, must match training.py.
      # [evidence_label, claim_label]
      y = {'claim_classification': tensors[8], 'evidence_matching': tensors[9]}
      return x, y
Read example from tfds and constructed named tensor inputs.
language/serene/preprocessing.py