<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def clean_ids(feed: "Feed") -> "Feed": """ In the given "Feed", strip whitespace from all string IDs and then replace every remaining whitespace chunk with an underscore. Return the resulting "Feed". """

    # Alter feed inputs only, and build a new feed from them.
    # The derived feed attributes, such as feed.trips_i,
    # will be automatically handled when creating the new feed.
    feed = feed.copy()

    for table in cs.GTFS_REF["table"].unique():
        f = getattr(feed, table)
        if f is None:
            continue
        for column in cs.GTFS_REF.loc[cs.GTFS_REF["table"] == table, "column"]:
            if column in f.columns and column.endswith("_id"):
                try:
                    f[column] = f[column].str.strip().str.replace(r"\s+", "_")
                    setattr(feed, table, f)
                except AttributeError:
                    # Column is not of string type
                    continue

    return feed