def realm_user_count_by_role(realm: Realm) -> Dict[(str, Any)]:
    human_counts = {UserProfile.ROLE_REALM_ADMINISTRATOR: 0, UserProfile.ROLE_REALM_OWNER: 0, UserProfile.ROLE_MEMBER: 0, UserProfile.ROLE_GUEST: 0}
    for value_dict in list(UserProfile.objects.filter(realm=realm, is_bot=False, is_active=True).values('role').annotate(Count('role'))):
        human_counts[value_dict['role']] = value_dict['role__count']
    bot_count = UserProfile.objects.filter(realm=realm, is_bot=True, is_active=True).count()
    return {RealmAuditLog.ROLE_COUNT_HUMANS: human_counts, RealmAuditLog.ROLE_COUNT_BOTS: bot_count}
def realm_user_count_by_role(realm: Realm) -> Dict[(str, Any)]:
    human_counts = {UserProfile.ROLE_REALM_ADMINISTRATOR: 0, UserProfile.ROLE_REALM_OWNER: 0, UserProfile.ROLE_MEMBER: 0, UserProfile.ROLE_GUEST: 0}
    for value_dict in list(UserProfile.objects.filter(realm=realm, is_bot=False, is_active=True).values('role').annotate(Count('role'))):
        human_counts[value_dict['role']] = value_dict['role__count']
    bot_count = UserProfile.objects.filter(realm=realm, is_bot=True, is_active=True).count()
    return {RealmAuditLog.ROLE_COUNT_HUMANS: human_counts, RealmAuditLog.ROLE_COUNT_BOTS: bot_count}