code: def copy_group(target, source, group):
      """Copy group to the target portal."""
      GROUP_COPY_PROPERTIES = [
          "title",
          "description",
          "tags",
          "snippet",
          "phone",
          "access",
          "isInvitationOnly",
      ]
      with tempfile.TemporaryDirectory() as temp_dir:
          # Create a new groups with the subset of properties we want to
          # copy to the target portal. Handle switching between org and
          # public access when going from an org in a multitenant portal
          # and a single tenant portal
          target_group = {}
  
          for property_name in GROUP_COPY_PROPERTIES:
              target_group[property_name] = group[property_name]
  
          if (
              target_group["access"] == "org"
              and target.properties["portalMode"] == "singletenant"
          ):
              target_group["access"] = "public"
          elif (
              target_group["access"] == "public"
              and source.properties["portalMode"] == "singletenant"
              and target.properties["portalMode"] == "multitenant"
              and "id" in target.properties
          ):  # is org
              target_group["access"] = "org"
  
          # Handle the thumbnail (if one exists)
          thumbnail_file = None
          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()
          copied_group.reassign_to(members["owner"])
          if members["users"]:
              copied_group.add_users(members["users"])
  
          # remove the admin user copying this group from the copied group if that
          #   username is not part of the group in the Source Portal
          if not target.users.me.username in members["users"]:
              copied_group.remove_users(target.users.me.username)
  
          return copied_group
  
imports: from __future__ import print_function
  import sys
  import six
  from arcgis.gis import *
label_desc: Use image node_id 2 for calling a global function with example usage: copy_group(target, source, group) and returns: copied_group