<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def remove_historical_group_permissions(group=None, allowed_permissions=None):
 """Removes group permissions for historical models except those whose prefix is in `allowed_historical_permissions`. Default removes all except `view`. """

    allowed_permissions = allowed_permissions or ["view"]

    for action in allowed_permissions:
        for permission in group.permissions.filter(
            codename__contains="historical"
        ).exclude(codename__startswith=action):
            group.permissions.remove(permission)