import collections


def FindApprovalsSubfields(approval_ids, config):
  """Return a dict of {approval_ids: approval_subfields}."""
  approval_subfields_dict = collections.defaultdict(list)
  for fd in config.field_defs:
    if fd.approval_id in approval_ids:
      approval_subfields_dict[fd.approval_id].append(fd)

  return approval_subfields_dict