code: def delete_groups(gis, user):
      """deletes the user groups, and removes user from groups where user is a member of"""
      groups_for_deletion = gis.groups.get(
          "query=owner:" + user.username
      )
      if groups_for_deletion is not None:
          for group in groups_for_deletion:
              try:
                  print("=== deleting group %s" % group.groupid)
                  group.delete()
              except:
                  print("=== could not delete group %s" % group.groupid)
  
      for grp in user.groups:
          print("=== removing from group: %s" % grp.id)
          if grp.owner != user.username:
              try:
                  grp.remove_users([user.username])
              except:
                  print(
                      "=== User cannot be removed from group: %s"
                      % grp.id
                  )
      print("=== finished deleting groups owned by " + user.username)
  
file_path: arcgis-python-api/misc/_common.py
imports: from arcgis.gis import GIS
label_desc: Use image node_id 5 for calling a global function with example usage: delete_groups(gis, user) without return types