def METHOD_NAME(
    subject_id: int,
    subject_type_name: str,
    scope_id: int,
    scope_type_name: str,
    workspace_id: int,
    permission_manager: PermissionManagerType = None,
):
    """
    Unsubscribes all users associated to a subject from the tables they are currently
    subscribed to. Optionally you can also recheck their permissions before deciding
    to unsubscribe them.
    :param subject_id: The id for the subject we are trying to unsubscribe
    :param subject_type_name: The name of the subject type
    :param scope_id: The id of the scope the subject should be removed from
    :param scope_type_name: The name of the scope type
    :param workspace_id: The id of the workspace in which context this is executed
    :param permission_manager: Optional parameter used to check permissions
    """
    from asgiref.sync import async_to_sync
    from channels.layers import get_channel_layer
    workspace = Workspace.objects.get(pk=workspace_id)
    subject_type = subject_type_registry.get(subject_type_name)
    scope_type = object_scope_type_registry.get(scope_type_name)
    if issubclass(subject_type.model_class, TrashableModelMixin):
        subject_type_qs = subject_type.model_class.objects_and_trash
    else:
        subject_type_qs = subject_type.model_class.objects
    subject = subject_type_qs.get(pk=subject_id)
    scope = scope_type.model_class.objects.get(pk=scope_id)
    users = subject_type.get_users_included_in_subject(subject)
    tables = DatabaseTableObjectScopeType().get_all_context_objects_in_scope(scope)
    channel_group_names_users_dict = defaultdict(set)
    for user in users:
        for table in tables:
            channel_group_name = TablePageType().get_group_name(table.id)
            if permission_manager is None:
                channel_group_names_users_dict[channel_group_name].add(user.id)
            else:
                try:
                    permission_manager.check_permissions(
                        user,
                        ListenToAllDatabaseTableEventsOperationType.type,
                        workspace=workspace,
                        context=table,
                    )
                except PermissionException:
                    channel_group_names_users_dict[channel_group_name].add(user.id)
    channel_layer = get_channel_layer()
    for channel_group_name, user_ids in channel_group_names_users_dict.items():
        async_to_sync(closing_group_send)(
            channel_layer,
            channel_group_name,
            {
                "type": "remove_user_from_group",
                "user_ids_to_remove": list(user_ids),
            },
        )