code: def set_socket_single_affinity(gpu_id, nproc_per_node, cores):
      """
      The process is assigned with the first available physical CPU core from the
      list of all CPU physical 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
      )
      single_grouped_socket_affinities = [
          group[:1] for group in grouped_socket_affinities
      ]
      ungrouped_affinities = ungroup_affinities(
          single_grouped_socket_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 10 for calling a global function with example usage: set_socket_single_affinity(gpu_id, nproc_per_node, cores) without return types