code: def _cpu_count_affinity(os_cpu_count):
      # Number of available CPUs given affinity settings
      if hasattr(os, "sched_getaffinity"):
          try:
              return len(os.sched_getaffinity(0))
          except NotImplementedError:
              pass
  
      # On PyPy and possibly other platforms, os.sched_getaffinity does not exist
      # or raises NotImplementedError, let's try with the psutil if installed.
      try:
          import psutil
  
          p = psutil.Process()
          if hasattr(p, "cpu_affinity"):
              return len(p.cpu_affinity())
  
      except ImportError:  # pragma: no cover
          if (
              sys.platform == "linux"
              and os.environ.get("LOKY_MAX_CPU_COUNT") is None
          ):
              # PyPy does not implement os.sched_getaffinity on Linux which
              # can cause severe oversubscription problems. Better warn the
              # user in this particularly pathological case which can wreck
              # havoc, typically on CI workers.
              warnings.warn(
                  "Failed to inspect CPU affinity constraints on this system. "
                  "Please install psutil or explictly set LOKY_MAX_CPU_COUNT."
              )
  
      # This can happen for platforms that do not implement any kind of CPU
      # infinity such as macOS-based platforms.
      return os_cpu_count
  
imports: import os
  import sys
  import math
  import subprocess
  import traceback
  import warnings
  import multiprocessing
  from multiprocessing import get_context
  from multiprocessing.context import BaseContext
  from .process import LokyProcess, LokyInitMainProcess
label_desc: Use image node_id 6 for calling a global function with example usage: _cpu_count_affinity(os_cpu_count) and returns: os_cpu_count, len, len