code: def set_socket_single_unique_affinity(gpu_id, nproc_per_node, cores):
      """
      The process is assigned with a single unique available physical CPU core
      from the list of all CPU cores from the CPU socket connected to the GPU with
      a given id.
  
      Args:
          gpu_id: index of a GPU
          nproc_per_node: number of processes per node
          cores: 'all_logical' or 'single_logical'
      """
      grouped_socket_affinities = get_grouped_socket_affinities(
          nproc_per_node
      )
  
      affinities = []
      assigned_groups = set()
  
      for grouped_socket_affinity in grouped_socket_affinities:
          for group in grouped_socket_affinity:
              if group not in assigned_groups:
                  affinities.append([group])
                  assigned_groups.add(group)
                  break
  
      ungrouped_affinities = ungroup_affinities(affinities, cores)
  
      os.sched_setaffinity(0, ungrouped_affinities[gpu_id])
  
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 11 for calling a global function with example usage: set_socket_single_unique_affinity(gpu_id, nproc_per_node, cores) without return types