code: def mp_exec(resources, configs, func):
      """
      @ resources : list of gpu devices
      @ configs : list of params
      @ func : f(dev,cfg)
      """
      q = Queue()
      for res in resources:
          q.put(res)
      pool = mp.Pool()
  
      def put_back_dev(dev, cfg):
          def callback(*args):
              print(f"Device {dev} Finish cfg {cfg} ")
              q.put(dev)
              print(*args)
  
          return callback
  
      for idx, cfg in enumerate(configs):
          dev = q.get()
          print(f"Start config {cfg} on device {dev}")
          pool.apply_async(
              func,
              args=[dev, cfg],
              callback=put_back_dev(dev, cfg),
              error_callback=put_back_dev(dev, cfg),
          )
  
      pool.close()
      pool.join()
  
file_path: AutoGL/test/nas/bench_mp.py
imports: import torch.multiprocessing
  from queue import Queue
  import time
  import random
  import os
  import pandas
label_desc: Use image node_id 1 for calling a global function with example usage: mp_exec(resources, configs, func) and returns: callback