def get_user_ids_for_streams(streams: Iterable[Stream]) -> Dict[(int, List[int])]:
    stream_ids = [stream.id for stream in streams]
    all_subs = get_active_subscriptions_for_stream_ids(stream_ids).filter(user_profile__is_active=True).values('recipient__type_id', 'user_profile_id').order_by('recipient__type_id')
    get_stream_id = itemgetter('recipient__type_id')
    all_subscribers_by_stream: Dict[(int, List[int])] = defaultdict(list)
    for (stream_id, rows) in itertools.groupby(all_subs, get_stream_id):
        user_ids = [row['user_profile_id'] for row in rows]
        all_subscribers_by_stream[stream_id] = user_ids
    return all_subscribers_by_stream
def get_user_ids_for_streams(streams: Iterable[Stream]) -> Dict[(int, List[int])]:
    stream_ids = [stream.id for stream in streams]
    all_subs = get_active_subscriptions_for_stream_ids(stream_ids).filter(user_profile__is_active=True).values('recipient__type_id', 'user_profile_id').order_by('recipient__type_id')
    get_stream_id = itemgetter('recipient__type_id')
    all_subscribers_by_stream: Dict[(int, List[int])] = defaultdict(list)
    for (stream_id, rows) in itertools.groupby(all_subs, get_stream_id):
        user_ids = [row['user_profile_id'] for row in rows]
        all_subscribers_by_stream[stream_id] = user_ids
    return all_subscribers_by_stream