from typing import Dict


def _make_title(grp_cnt_stats: Dict[str, int], x: str, y: str) -> str:
    """
    Format the title to notify the user of sampled output
    """

    x_ttl = grp_cnt_stats["x_ttl"]
    x_show = grp_cnt_stats["x_show"]
    if "y_ttl" in grp_cnt_stats:
        y_ttl = grp_cnt_stats["y_ttl"]
        y_show = grp_cnt_stats["y_show"]

        if x_ttl > x_show and y_ttl > y_show:
            return "(top {} out of {}) {} by (top {} out of {}) {}".format(
                y_show, y_ttl, y, x_show, x_ttl, x
            )
        if y_ttl > y_show:
            return "(top {} out of {}) {} by {}".format(y_show, y_ttl, y, x)
    if x_ttl > x_show:
        return "{} by (top {} out of {}) {}".format(y, x_show, x_ttl, x)
    return f"{y} by {x}"