code: def _determine_effective_cpu_limit():
      """Calculate CPU limit (in number of cores) based on:
  
      - /sys/fs/cgroup/cpu/cpu.max (if available, cgroup 2)
      OR
      - /sys/fs/cgroup/cpu/cpu.cfs_quota_us
      - /sys/fs/cgroup/cpu/cpu.cfs_period_us
  
      Returns:
          > 0 if limit was successfully calculated
          = 0 if we determined that there is no limit
          -1 if we failed to determine the limit
      """
      try:
          if platform.system() == "Darwin":
              # On MacOS, and not in a container
              # We are assuming it is extremely out-of-the-way to run a Darwin container
              return 0
          elif platform.system() == "Linux":
              # Bare metal Linux, or a Linux container running on either Linux or MacOS system
              # Linux containers on MacOS have this cpu.max file
              with open("/sys/fs/cgroup/cpu.max", "rb") as f:
                  parts = f.read().decode("utf-8").split(" ")
                  if len(parts) == 2:
                      if parts[0] == "max":
                          return 0
                      return int(parts[0]) / int(parts[1])
  
              with open(
                  "/sys/fs/cgroup/cpu/cpu.cfs_quota_us", "rb"
              ) as f:
                  quota = int(f.read())
                  # this file shows -1 for no limit
                  if quota == -1:
                      return 0
                  # some other negative number - this is weird...return "undetermined"
                  if quota < 0:
                      return -1
              with open(
                  "/sys/fs/cgroup/cpu/cpu.cfs_period_us", "rb"
              ) as f:
                  period = int(f.read())
                  # should be positive. we don't want div by zero errors.
                  if period <= 0:
                      return -1
                  return quota / period
          else:
              # Not Linux or MacOS...give up and return "undetermined"
              return -1
      except Exception:
          return -1
  
file_path: metaflow/metaflow/plugins/storage_executor.py
imports: import math
  import multiprocessing
  import os
  import platform
  import sys
  from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor
  from metaflow.exception import MetaflowException
label_desc: Use image node_id 1 for calling a global function with example usage: _determine_effective_cpu_limit() and returns: int, unknown, unknown, unknown, unknown, int, unknown, unknown, int