def format_targets(ranking, targets_format):
    """
    Returns the generation targets as a list of str, depending on targets_format.

    Args:
        ranking: list of (inputs, targets) batches
        targets_format: str, version of the targets format to use.
    """

    valid_choices = []
    for inputs, targets in ranking:
        for choice, target in zip(inputs['choices'], targets):
            if target:
                valid_choices.append(choice)

    if targets_format == "v0":  # one target per valid choice
        return valid_choices

    elif targets_format == "v1":  # all valid choices in one target, separated with separation tokens.
        return ["∂ " + " ∂ ".join(valid_choices)]

    else:
        raise Exception("Targets format not implemented: %s." % targets_format)