def format_timedelta(td: timedelta) -> str:
    """
    Format a timedelta for humans.
    """
    if td.days > 1:
        return f"{td.days} days"
    elif td.days > 0:
        return f"{td.days} day"
    else:
        hours, remainder = divmod(td.seconds, 3600)
        minutes, _ = divmod(remainder, 60)
        if hours > 1:
            return f"{hours} hours"
        elif hours > 0:
            return f"{hours} hour, {minutes} mins"
        else:
            return f"{minutes} mins"
Format a timedelta for humans.
allennlp/common/util.py