code: def schedule_workers(
      num_workers: int, cores_per_worker: Optional[int] = None
  ):
      # If we are in a docker container whose --cpuset-cpus are set,
      # we can get available cpus in /sys/fs/cgroup/cpuset/cpuset.cpus.
      # If we are not in a container, this just return all cpus.
      cpuset = get_cgroup_cpuset()
      cpuset = sorted(cpuset)
      l_core_to_p_core, l_core_to_socket = get_cpu_info()
  
      p2l = {}
      p_cores = set()
      for logical_core in cpuset:
          physical_core = l_core_to_p_core[logical_core]
          p_cores.add(physical_core)
          if physical_core not in p2l:
              p2l[physical_core] = logical_core
      p_cores = sorted(p_cores)
  
      if cores_per_worker is None:
          cores_per_worker = len(p_cores) // num_workers
  
      msg = (
          "total number of cores requested must be smaller or"
          " equal than the physical cores available"
      )
      invalidInputError(
          cores_per_worker * num_workers <= len(p_cores), msg
      )
  
      schedule = []
      for i in range(num_workers):
          schedule.append(
              [
                  p2l[core]
                  for core in p_cores[
                      i * cores_per_worker : (i + 1) * cores_per_worker
                  ]
              ]
          )
  
      return schedule
  
imports: import subprocess
  import re
  from typing import Optional
  from bigdl.dllib.utils.log4Error import *
label_desc: Use image node_id 3 for calling a global function with example usage: schedule_workers(num_workers, cores_per_worker) and returns: schedule