def assign_records(
    users: Union[Dict[str, List[Any]], List[Any]], records: List[Any], overlap: int, shuffle: bool = True
) -> Union[Dict[str, List[Any]], Dict[str, Dict[str, Any]]]:
    """
    Assign records to either groups or individuals, with controlled overlap and optional shuffle.

    Args:
        users: Either a dictionary of groups or a list of individual user objects.
        records: A list of record objects to be assigned.
        overlap: The number of times each record is assigned to consecutive users or groups (0 for no overlap).
        shuffle: If True, the records list will be shuffled before assignment. Defaults to True.

    Returns:
        A dictionary where each key is a group and its value is another dictionary, which maps usernames to their respective assigned records.
        Or a dictionary where keys are usernames and values are lists of assigned records.

    Examples:
        >>> from argilla_v1.client.feedback.utils import assign_records
        >>> individual_assignments = assign_records([user1, user2, user3], records, 0, False)
        >>> group_assignments = assign_records({group1: [user1, user2], group2: [user3]}, records, 1, False)

    """
    if isinstance(users, dict):
        return assign_records_to_groups(users, records, overlap, shuffle)
    elif isinstance(users, list):
        return assign_records_to_individuals(users, records, overlap, shuffle)

    Assign records to either groups or individuals, with controlled overlap and optional shuffle.

    Args:
        users: Either a dictionary of groups or a list of individual user objects.
        records: A list of record objects to be assigned.
        overlap: The number of times each record is assigned to consecutive users or groups (0 for no overlap).
        shuffle: If True, the records list will be shuffled before assignment. Defaults to True.

    Returns:
        A dictionary where each key is a group and its value is another dictionary, which maps usernames to their respective assigned records.
        Or a dictionary where keys are usernames and values are lists of assigned records.

    Examples:
        >>> from argilla_v1.client.feedback.utils import assign_records
        >>> individual_assignments = assign_records([user1, user2, user3], records, 0, False)
        >>> group_assignments = assign_records({group1: [user1, user2], group2: [user3]}, records, 1, False)

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