def _merge_prefix_and_labels(prefixes, labels):
  """Merges file prefixes and mturk labels into a dict with screen id as key."""
  screen_id_to_labels = {}

  for screen_id, captions in labels.items():
    if screen_id not in screen_id_to_labels:
      screen_id_to_labels[screen_id] = {}
    screen_id_to_labels[screen_id]['labels'] = captions

  for screen_id, prefix in prefixes:
    if screen_id in screen_id_to_labels:
      screen_id_to_labels[screen_id]['prefix'] = prefix

  return screen_id_to_labels.values()