code: def cpu_count():
      """Get the available CPU count for this system.
  
      Takes the minimum value from the following locations:
  
      - Total system cpus available on the host.
      - CPU Affinity (if set)
      - Cgroups limit (if set)
      """
      count = os.cpu_count()
  
      # Check CPU affinity if available
      if psutil is not None:
          try:
              affinity_count = len(psutil.Process().cpu_affinity())
              if affinity_count > 0:
                  count = min(count, affinity_count)
          except Exception:
              pass
  
      # Check cgroups if available
      if sys.platform == "linux":
          quota, period = _try_extract_cgroup_cpu_quota()
          if quota is not None and period is not None:
              # We round up on fractional CPUs
              cgroups_count = math.ceil(quota / period)
              if cgroups_count > 0:
                  count = min(count, cgroups_count)
  
      return count
  
imports: from __future__ import annotations
  import math
  import os
  import sys
label_desc: Use image node_id 2 for calling a global function with example usage: cpu_count() and returns: count