def preprocess_mapper(features, params, lookup_table, vocab):
  """Model-specific preprocessing of features from the dataset."""
  # Set input type.
  features["input_type"] = tf.constant(datasets.DatasetTypes.GUIDED)

  caption = text_utils.build_text_inputs(
      text=features["caption"],
      length=params["caption_length"],
      lookup_table=lookup_table,
      segment_id=0,
      start_token=vocab.CLS,
      end_token=vocab.SEP)
  assert isinstance(caption, text_utils.TextInputs)

  features["token_inputs"] = text_utils.TextInputs(
      token_ids=caption.token_ids[:-1],
      mask=caption.mask[:-1],
      segment_ids=caption.segment_ids[:-1],
      positions=caption.positions[:-1])

  features["token_outputs"] = text_utils.TextOutputs(
      token_ids=caption.token_ids[1:], mask=caption.mask[1:])

  features["condition_inputs"] = text_utils.build_planner_inputs(
      question=features["question"],
      answer=features["answer"],
      length=params["condition_length"],
      lookup_table=lookup_table)

  features["object_features"] = image_utils.parse_object_features(
      features["object_features"], features["object_positions"], params)

  # Remove extra inputs.
  features = {f: features[f] for f in features if f in KEYS}

  # Add dummy inputs for standardization for multi-tasking.
  for k, v in datasets.footprint(params).items():
    if k not in features:
      features[k] = v

  return features
Model-specific preprocessing of features from the dataset.
language/capwap/datasets/wsp_dataset.py