code: def process_data(
      groupsMemberships_file,
      flickr_links_file,
      users_label_file,
      edges_file,
      users_file,
  ):
      """Preprocess flickr network dataset.
  
      Args:
          groupsMemberships_file: flickr-groupmemberships.txt file,
              each line is a pair (user, group), which indicates a user belongs to a group.
  
          flickr_links_file: flickr-links.txt file,
              each line is a pair (user, user), which indicates
              the two users have a relationship.
  
          users_label_file: each line is a pair (user, list of group),
              each user may belong to multiple groups.
  
          edges_file: each line is a pair (user, user), which indicates
              the two users have a relationship. It filters some unused edges.
  
          users_file: each line is a int number, which indicates the ID of a user.
      """
      group2users = {}
      with open(groupsMemberships_file, "r") as f:
          for line in f:
              user, group = line.strip().split()
              try:
                  group2users[int(group)].append(user)
              except:
                  group2users[int(group)] = [user]
  
      # counting how many users belong to every group
      group2usersNum = {}
      for key, item in group2users.items():
          group2usersNum[key] = len(item)
  
      groups_sorted_by_usersNum = sorted(
          group2usersNum.items(),
          key=operator.itemgetter(1),
          reverse=True,
      )
  
      # the paper only need the 5 groups with the largest number of users
      label = 1  # remapping the 5 groups from 1 to 5
      users_label = {}
      for i in range(5):
          users_list = group2users[groups_sorted_by_usersNum[i][0]]
          for user in users_list:
              # one user may have multi-labels
              try:
                  users_label[user].append(label)
              except:
                  users_label[user] = [label]
          label += 1
  
      # remapping the users IDs to make the IDs from 0 to N
      userID2nodeID = {}
      count = 1
      for key in sorted(users_label.keys()):
          userID2nodeID[key] = count
          count += 1
  
      with open(users_label_file, "w") as writer:
          for key in sorted(users_label.keys()):
              line = " ".join([str(i) for i in users_label[key]])
              writer.write(str(userID2nodeID[key]) + "," + line + "\n")
  
      # produce edges file
      with open(flickr_links_file, "r") as reader, open(
          edges_file, "w"
      ) as writer:
          for line in reader:
              src, dst = line.strip().split("\t")
              # filter unused user IDs
              if src in users_label and dst in users_label:
                  # remapping the users IDs
                  src = userID2nodeID[src]
                  dst = userID2nodeID[dst]
  
                  writer.write(str(src) + "\t" + str(dst) + "\n")
  
      # produce nodes file
      with open(users_file, "w") as writer:
          for i in range(1, 1 + len(userID2nodeID)):
              writer.write(str(i) + "\n")
  
label_desc: Use image node_id 1 for calling a global function with example usage: process_data(groupsMemberships_file, flickr_links_file, users_label_file, edges_file, users_file) without return types