code: 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.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
  
file_path: argilla/src/argilla/client/feedback/utils/assignment.py
imports: import random
  import warnings
  from collections import defaultdict
  from typing import Any, Dict, List, Union
  from rich.progress import Progress
  from argilla.client.users import User
  from argilla.client.workspaces import Workspace
label_desc: Use image node_id 6 for calling a global function with example usage: assign_workspaces(assignments, workspace_type) and returns: wk_assignments