code: def num_available_cpu_cores(ram_per_build_process_in_gb):
      if "TRAVIS" in os.environ and os.environ["TRAVIS"] == "true":
          # When building on travis-ci, just use 2 cores since travis-ci limits
          # you to that regardless of what the hardware might suggest.
          return 2
      elif (
          "CMAKE_BUILD_PARALLEL_LEVEL" in os.environ
          and os.environ["CMAKE_BUILD_PARALLEL_LEVEL"].isnumeric()
      ):
          return int(os.environ["CMAKE_BUILD_PARALLEL_LEVEL"])
      try:
          mem_bytes = os.sysconf("SC_PAGE_SIZE") * os.sysconf(
              "SC_PHYS_PAGES"
          )
          mem_gib = mem_bytes / (1024.0**3)
          num_cores = multiprocessing.cpu_count()
          # make sure we have enough ram for each build process.
          mem_cores = int(
              floor(mem_gib / float(ram_per_build_process_in_gb) + 0.5)
          )
          # We are limited either by RAM or CPU cores.  So pick the limiting amount
          # and return that.
          return max(min(num_cores, mem_cores), 1)
      except ValueError:
          return 2
  
imports: import os
  import re
  import sys
  import shutil
  import platform
  import subprocess
  import multiprocessing
  from distutils import log
  from math import ceil, floor
  from setuptools import find_packages, setup, Extension
  from setuptools.command.build_ext import build_ext
  from distutils.version import LooseVersion
  from setuptools.command.test import test
label_desc: Use image node_id 3 for calling a global function with example usage: num_available_cpu_cores(ram_per_build_process_in_gb) and returns: int, max, int, int