code: def group_affinity_by_siblings(socket_affinities):
      siblings_list = get_thread_siblings_list()
      siblings_dict = build_thread_siblings_dict(siblings_list)
  
      grouped_socket_affinities = []
  
      for socket_affinity in socket_affinities:
          grouped_socket_affinities.append(
              group_list_by_dict(socket_affinity, siblings_dict)
          )
      return grouped_socket_affinities
  
imports: import collections
  import itertools
  import os
  import pathlib
  import re
  import pynvml
  from typing import Union
  from enum import Enum, auto
label_desc: Use image node_id 4 for calling a global function with example usage: group_affinity_by_siblings(socket_affinities) and returns: grouped_socket_affinities