def _entities_to_choices(entities, answer):
  """Generate a multichoice question template."""
  if len(entities) > 26:
    raise ValueError('Too many choices: {}'.format(len(entities)))

  entity_dict = {}
  choices_template = ''
  answer_choice = None
  for i, entity in enumerate(entities):
    choices_template += '  '
    entity_name = 'entity_{}'.format(i)
    entity_dict[entity_name] = entity
    letter = chr(ord('a') + i)
    choices_template += '({letter}) {{{entity_name}}}'.format(
        letter=letter, entity_name=entity_name)
    if entity is answer:
      assert answer_choice is None
      answer_choice = letter

  assert answer_choice is not None
  return entity_dict, choices_template, answer_choice