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.VQA)

  # Fix question id.
  features["question_id"] = tf.ensure_shape(features["question_id"], [])

  features["question_inputs"] = text_utils.build_text_inputs(
      text=features["question"],
      length=params["question_length"],
      lookup_table=lookup_table,
      segment_id=0)

  answer = text_utils.build_text_inputs(
      text=features["answer"],
      length=params["answer_length"],
      lookup_table=lookup_table,
      segment_id=1,
      start_token=vocab.ANS)
  assert isinstance(answer, text_utils.TextInputs)

  features["answer_inputs"] = answer

  features["answer_outputs"] = text_utils.TextOutputs(
      token_ids=answer.token_ids[1:], mask=answer.mask[1:])

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

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

  # 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/vqa_dataset.py