def ensure_list(iterable: Iterable[A]) -> List[A]:
    """
    An Iterable may be a list or a generator.
    This ensures we get a list without making an unnecessary copy.
    """
    if isinstance(iterable, list):
        return iterable
    else:
        return list(iterable)
An Iterable may be a list or a generator.
This ensures we get a list without making an unnecessary copy.
allennlp/common/util.py