code: def copy_group(target, source, source_group):
      with tempfile.TemporaryDirectory() as temp_dir:
          try:
              target_group = {}
  
              for property_name in GROUP_COPY_PROPERTIES:
                  target_group[property_name] = source_group[
                      property_name
                  ]
  
              if (
                  source_group["access"] == "org"
                  and target.properties["portalMode"] == "singletenant"
              ):
                  # cloning from ArcGIS Online to ArcGIS Enterprise
                  target_group["access"] = "public"
  
              elif (
                  source_group["access"] == "public"
                  and source.properties["portalMode"] == "singletenant"
                  and target.properties["portalMode"] == "multitenant"
                  and "id" in target.properties
              ):
                  # cloning from ArcGIS Enterprise to ArcGIS Online org
                  target_group["access"] = "org"
  
              # Download the thumbnail (if one exists)
              if "thumbnail" in group:
                  target_group["thumbnail"] = group.download_thumbnail(
                      temp_dir
                  )
  
              # Create the group in the target portal
              copied_group = target.groups.create_from_dict(
                  target_group
              )
  
              # Reassign all groups to correct owners, add users, and find shared items
              members = group.get_members()
              if not members["owner"] == target_admin_username:
                  copied_group.reassign_to(members["owner"])
              if members["users"]:
                  copied_group.add_users(members["users"])
              return copied_group
          except:
              print("Error creating " + source_group["title"])
  
imports: from arcgis.gis import GIS
  from getpass import getpass
  import tempfile
label_desc: Use image node_id 2 for calling a global function with example usage: copy_group(target, source, source_group) and returns: copied_group