code: def _get_cpu_count_on_localhost() -> float:
      """Fail-safe method to get cpu count. Also respects docker/cgroup limitations."""
      try:
          import psutil
  
          cpu_count = psutil.cpu_count()
      except:  # noqa: E722
          # psutil is probably not installed
          cpu_count = os.cpu_count()
  
      try:
          import math
  
          # Try to read out docker cpu quota if it exists
          quota_file = "/sys/fs/cgroup/cpu/cpu.cfs_quota_us"
          if os.path.isfile(quota_file):
              cpu_quota = math.ceil(
                  int(
                      os.popen("cat " + quota_file)
                      .read()
                      .replace("\n", "")
                  )
                  / 100000
              )
              if 0 < cpu_quota < cpu_count:
                  cpu_count = cpu_quota
      except:  # noqa: E722
          # Do nothing
          pass
  
      return cpu_count
  
imports: import os
  import platform
  import socket
  import subprocess
  import sys
  from typing import Dict, List, Union
  import lazycluster.settings
  from .utils import Environment
label_desc: Use image node_id 10 for calling a global function with example usage: _get_cpu_count_on_localhost() and returns: cpu_count