def assign_workspaces(
    assignments: Union[Dict[str, List[Any]], Dict[str, Dict[str, Any]]], workspace_type: str
) -> Dict[str, List[Any]]:
    """
    Assign workspaces (and create them if needed) to either groups or individuals.

    Args:
        assignments: Either a dictionary of groups or a dictionary of users.
        workspace_type: Either 'group' (each group in a workspace), 'group_personal' (each member in a workspace) or 'individual' (each person in a workspace).

    Returns:
        A dictionary where each key is a workspace name and its value is a list of user names.

    Examples:
        >>> from argilla_v1.client.feedback.utils import assign_workspaces
        >>> wk_assignments = assign_workspaces(group_assignments, "group")
        >>> wk_assignments = assign_workspaces(group_assignments, "group_personal")
        >>> wk_assignments = assign_workspaces(individual_assignments, "individual")

    """
    wk_assignments = {}

    for group, users in assignments.items():
        if workspace_type == "group":
            workspace_name = group
            user_ids = [check_user(user).id for user in users.keys()]

        elif workspace_type == "group_personal":
            for user in users.keys():
                workspace_name = user
                user_ids = [check_user(user).id]
                workspace = check_workspace(workspace_name)

                for user_id in user_ids:
                    try:
                        workspace.add_user(user_id)
                    except:
                        pass

                wk_assignments[workspace_name] = [User.from_id(user.id).username for user in workspace.users]

            continue

        elif workspace_type == "individual":
            workspace_name = group
            user_ids = [check_user(group).id]

        workspace = check_workspace(workspace_name)

        for user_id in user_ids:
            try:
                workspace.add_user(user_id)
            except:
                pass

        wk_assignments[workspace_name] = [User.from_id(user.id).username for user in workspace.users]

    return wk_assignments

    Assign workspaces (and create them if needed) to either groups or individuals.

    Args:
        assignments: Either a dictionary of groups or a dictionary of users.
        workspace_type: Either 'group' (each group in a workspace), 'group_personal' (each member in a workspace) or 'individual' (each person in a workspace).

    Returns:
        A dictionary where each key is a workspace name and its value is a list of user names.

    Examples:
        >>> from argilla_v1.client.feedback.utils import assign_workspaces
        >>> wk_assignments = assign_workspaces(group_assignments, "group")
        >>> wk_assignments = assign_workspaces(group_assignments, "group_personal")
        >>> wk_assignments = assign_workspaces(individual_assignments, "individual")

    
argilla-v1/src/argilla_v1/client/feedback/utils/assignment.py