class_docstr: Parallelisation wrapper for working with map-like callables, such as
  `multiprocessing.Pool.map`.
  
  Parameters
  ----------
  pool : int or map-like callable
      If `pool` is an integer, then it specifies the number of threads to
      use for parallelization. If ``int(pool) == 1``, then no parallel
      processing is used and the map builtin is used.
      If ``pool == -1``, then the pool will utilize all available CPUs.
      If `pool` is a map-like callable that follows the same
      calling sequence as the built-in map function, then this callable is
      used for parallelization.
class_docstr_tok: ["Parallelisation","wrapper","for","working","with","map-like","callables",",","such","as","`","multiprocessing.Pool.map","`",".","Parameters","--","--","--","--","--","pool",":","int","or","map-like","callable","If","`","pool","`","is","an","integer",",","then","it","specifies","the","number","of","threads","to","use","for","parallelization",".","If","``","int","(","pool",")","==","1","``",",","then","no","parallel","processing","is","used","and","the","map","builtin","is","used",".","If","``","pool","==","-1","``",",","then","the","pool","will","utilize","all","available","CPUs",".","If","`","pool","`","is","a","map-like","callable","that","follows","the","same","calling","sequence","as","the","built-in","map","function",",","then","this","callable","is","used","for","parallelization","."]
code: def __init__(self, pool=1):
      self.pool = None
      self._mapfunc = map
      self._own_pool = False
  
      if callable(pool):
          self.pool = pool
          self._mapfunc = self.pool
      else:
          from multiprocessing import Pool
  
          # user supplies a number
          if int(pool) == -1:
              # use as many processors as possible
              self.pool = Pool()
              self._mapfunc = self.pool.map
              self._own_pool = True
          elif int(pool) == 1:
              pass
          elif int(pool) > 1:
              # use the number of processors requested
              self.pool = Pool(processes=int(pool))
              self._mapfunc = self.pool.map
              self._own_pool = True
          else:
              raise RuntimeError(
                  "Number of workers specified must be -1,"
                  " an int >= 1, or an object with a 'map' "
                  "method"
              )
  
imports: from contextlib import contextmanager
  import functools
  import operator
  import sys
  import warnings
  import numbers
  from collections import namedtuple
  import inspect
  import math
  from typing import Optional, Union, TYPE_CHECKING, TypeVar
  import numpy
label_desc: Use image node_id 1 to create a new MapWrapper object  with example: obj = MapWrapper(pool)