code: def group_list_by_dict(affinity, siblings_dict):
      sorted_affinity = sorted(
          affinity, key=lambda x: siblings_dict.get(x, (x,))
      )
      grouped = itertools.groupby(
          sorted_affinity, key=lambda x: siblings_dict.get(x, (x,))
      )
      grouped_affinity = []
      for key, group in grouped:
          grouped_affinity.append(tuple(group))
      return grouped_affinity
  
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 3 for calling a global function with example usage: group_list_by_dict(affinity, siblings_dict) and returns: grouped_affinity