code: def get_cpu_affinity(self):
      affinity_string = ""
      for j in pynvml.nvmlDeviceGetCpuAffinity(
          self.handle, Device._nvml_affinity_elements
      ):
          # assume nvml returns list of 64 bit ints
          affinity_string = "{:064b}".format(j) + affinity_string
  
      affinity_list = [int(x) for x in affinity_string]
      affinity_list.reverse()  # so core 0 is in 0th element of list
  
      ret = [i for i, e in enumerate(affinity_list) if e != 0]
      return ret
  
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 the Device obj's underlying member method code with example usage: obj.get_cpu_affinity() and returns: ret