code: def proc_count(core_div=2, max_default=None, level=0):
      """
      Get the number of desired jobs for multiprocessing operations.  This does not
      affect Numba or MKL multithreading.
  
      This count can come from a number of sources:
  
      * The ``LK_NUM_PROCS`` environment variable
      * The number of CPUs, divided by ``core_div`` (default 2)
  
      Args:
          core_div(int or None):
              The divisor to scale down the number of cores; ``None`` to turn off core-based
              fallback.
          max_default:
              The maximum number of processes to use if the environment variable is not
              configured.
          level:
              The process nesting level.  0 is the outermost level of parallelism; subsequent
              levels control nesting.  Levels deeper than 1 are rare, and it isn't expected
              that callers actually have an accurate idea of the threading nesting, just that
              they are configuring a child.  If the process count is unconfigured, then level
              1 will use ``core_div``, and deeper levels will use 1.
  
      Returns:
          int: The number of jobs desired.
      """
  
      nprocs = os.environ.get("LK_NUM_PROCS", None)
      if nprocs is not None:
          nprocs = [int(s) for s in nprocs.split(",")]
      elif core_div is not None:
          nprocs = max(mp.cpu_count() // core_div, 1)
          if max_default is not None:
              nprocs = min(nprocs, max_default)
          nprocs = [nprocs, core_div]
  
      if level >= len(nprocs):
          return 1
      else:
          return nprocs[level]
  
imports: import os
  import multiprocessing
  from multiprocessing.queues import SimpleQueue
  import functools
  import logging
  import logging.handlers
  import faulthandler
  from concurrent.futures import ProcessPoolExecutor
  from abc import ABC, abstractmethod
  import pickle
  from threadpoolctl import threadpool_limits
  import seedbank
  from lenskit.sharing import persist, PersistedModel
  from lenskit.util.log import log_queue
label_desc: Use image node_id 9 for calling a global function with example usage: proc_count(core_div, max_default, level) and returns: int, nprocs