code: def eval_with_funcs(
      predictors, nr_eval, get_player_fn, verbose=False
  ):
      """
      Args:
          predictors ([PredictorBase])
      """
  
      class Worker(StoppableThread, ShareSessionThread):
          def __init__(self, func, queue):
              super(Worker, self).__init__()
              self._func = func
              self.q = queue
  
          def func(self, *args, **kwargs):
              if self.stopped():
                  raise RuntimeError("stopped!")
              return self._func(*args, **kwargs)
  
          def run(self):
              with self.default_sess():
                  player = get_player_fn(train=False)
                  while not self.stopped():
                      try:
                          score = play_one_episode(player, self.func)
                      except RuntimeError:
                          return
                      self.queue_put_stoppable(self.q, score)
  
      q = queue.Queue()
      threads = [Worker(f, q) for f in predictors]
  
      for k in threads:
          k.start()
          time.sleep(0.1)  # avoid simulator bugs
      stat = StatCounter()
  
      def fetch():
          r = q.get()
          stat.feed(r)
          if verbose:
              logger.info("Score: {}".format(r))
  
      for _ in get_tqdm(range(nr_eval)):
          fetch()
      # waiting is necessary, otherwise the estimated mean score is biased
      logger.info(
          "Waiting for all the workers to finish the last run..."
      )
      for k in threads:
          k.stop()
      for k in threads:
          k.join()
      while q.qsize():
          fetch()
  
      if stat.count > 0:
          return (stat.average, stat.max)
      return (0, 0)
  
file_path: tensorpack/examples/A3C-Gym/common.py
imports: import multiprocessing
  import numpy
  import random
  import time
  from six.moves import queue
  from tensorpack.callbacks import Callback
  from tensorpack.utils import logger, get_tqdm
  from tensorpack.utils.concurrency import ShareSessionThread, StoppableThread
  from tensorpack.utils.stats import StatCounter
label_desc: Use image node_id 3 for calling a global function with example usage: eval_with_funcs(predictors, nr_eval, get_player_fn, verbose) and returns: int,  int, stat,  stat, self