class_docstr: Reducer callable to dump large arrays to memmap files.
  
  Parameters
  ----------
  max_nbytes: int
      Threshold to trigger memmapping of large arrays to files created
      a folder.
  temp_folder_resolver: callable
      An callable in charge of resolving a temporary folder name where files
      for backing memmapped arrays are created.
  mmap_mode: 'r', 'r+' or 'c'
      Mode for the created memmap datastructure. See the documentation of
      numpy.memmap for more details. Note: 'w+' is coerced to 'r+'
      automatically to avoid zeroing the data on unpickling.
  verbose: int, optional, 0 by default
      If verbose > 0, memmap creations are logged.
      If verbose > 1, both memmap creations, reuse and array pickling are
      logged.
  prewarm: bool, optional, False by default.
      Force a read on newly memmapped array to make sure that OS pre-cache it
      memory. This can be useful to avoid concurrent disk access when the
      same data array is passed to different worker processes.
class_docstr_tok: ["Reducer","callable","to","dump","large","arrays","to","memmap","files",".","Parameters","--","--","--","--","--","max_nbytes",":","int","Threshold","to","trigger","memmapping","of","large","arrays","to","files","created","a","folder",".","temp_folder_resolver",":","callable","An","callable","in","charge","of","resolving","a","temporary","folder","name","where","files","for","backing","memmapped","arrays","are","created",".","mmap_mode",":","'","r","'",",","'","r+","'","or","'","c'","Mode","for","the","created","memmap","datastructure",".","See","the","documentation","of","numpy.memmap","for","more","details",".","Note",":","'","w+","'","is","coerced","to","'","r+'","automatically","to","avoid","zeroing","the","data","on","unpickling",".","verbose",":","int",",","optional",",","0","by","default","If","verbose",">","0",",","memmap","creations","are","logged",".","If","verbose",">","1",",","both","memmap","creations",",","reuse","and","array","pickling","are","logged",".","prewarm",":","bool",",","optional",",","False","by","default",".","Force","a","read","on","newly","memmapped","array","to","make","sure","that","OS","pre-cache","it","memory",".","This","can","be","useful","to","avoid","concurrent","disk","access","when","the","same","data","array","is","passed","to","different","worker","processes","."]
code: def __call__(self, a):
      m = _get_backing_memmap(a)
      if m is not None and isinstance(m, np.memmap):
          # a is already backed by a memmap file, let's reuse it directly
          return _reduce_memmap_backed(a, m)
  
      if (
          not a.dtype.hasobject
          and self._max_nbytes is not None
          and a.nbytes > self._max_nbytes
      ):
          # check that the folder exists (lazily create the pool temp folder
          # if required)
          try:
              os.makedirs(self._temp_folder)
              os.chmod(self._temp_folder, FOLDER_PERMISSIONS)
          except OSError as e:
              if e.errno != errno.EEXIST:
                  raise e
  
          try:
              basename = self._memmaped_arrays.get(a)
          except KeyError:
              # Generate a new unique random filename. The process and thread
              # ids are only useful for debugging purpose and to make it
              # easier to cleanup orphaned files in case of hard process
              # kill (e.g. by "kill -9" or segfault).
              basename = "{}-{}-{}.pkl".format(
                  os.getpid(),
                  id(threading.current_thread()),
                  uuid4().hex,
              )
              self._memmaped_arrays.set(a, basename)
          filename = os.path.join(self._temp_folder, basename)
  
          # In case the same array with the same content is passed several
          # times to the pool subprocess children, serialize it only once
  
          is_new_memmap = (
              filename not in self._temporary_memmaped_filenames
          )
  
          # add the memmap to the list of temporary memmaps created by joblib
          self._temporary_memmaped_filenames.add(filename)
  
          if self._unlink_on_gc_collect:
              # Bump reference count of the memmap by 1 to account for
              # shared usage of the memmap by a child process. The
              # corresponding decref call will be executed upon calling
              # resource_tracker.maybe_unlink, registered as a finalizer in
              # the child.
              # the incref/decref calls here are only possible when the child
              # and the parent share the same resource_tracker. It is not the
              # case for the multiprocessing backend, but it does not matter
              # because unlinking a memmap from a child process is only
              # useful to control the memory usage of long-lasting child
              # processes, while the multiprocessing-based pools terminate
              # their workers at the end of a map() call.
              resource_tracker.register(filename, "file")
  
          if is_new_memmap:
              # Incref each temporary memmap created by joblib one extra
              # time.  This means that these memmaps will only be deleted
              # once an extra maybe_unlink() is called, which is done once
              # all the jobs have completed (or been canceled) in the
              # Parallel._terminate_backend() method.
              resource_tracker.register(filename, "file")
  
          if not os.path.exists(filename):
              util.debug(
                  "[ARRAY DUMP] Pickling new array (shape={}, dtype={}) "
                  "creating a new memmap at {}".format(
                      a.shape, a.dtype, filename
                  )
              )
              for dumped_filename in dump(a, filename):
                  os.chmod(dumped_filename, FILE_PERMISSIONS)
  
              if self._prewarm:
                  # Warm up the data by accessing it. This operation ensures
                  # that the disk access required to create the memmapping
                  # file are performed in the reducing process and avoids
                  # concurrent memmap creation in multiple children
                  # processes.
                  load(filename, mmap_mode=self._mmap_mode).max()
  
          else:
              util.debug(
                  "[ARRAY DUMP] Pickling known array (shape={}, dtype={}) "
                  "reusing memmap file: {}".format(
                      a.shape, a.dtype, os.path.basename(filename)
                  )
              )
  
          # The worker process will use joblib.load to memmap the data
          return (
              load_temporary_memmap,
              (filename, self._mmap_mode, self._unlink_on_gc_collect),
          )
      else:
          # do not convert a into memmap, let pickler do its usual copy with
          # the default system pickler
          util.debug(
              "[ARRAY DUMP] Pickling array (NO MEMMAPPING) (shape={}, "
              " dtype={}).".format(a.shape, a.dtype)
          )
          return (loads, (dumps(a, protocol=HIGHEST_PROTOCOL),))
  
imports: from mmap import mmap
  import errno
  import os
  import stat
  import threading
  import atexit
  import tempfile
  import time
  import warnings
  import weakref
  from uuid import uuid4
  from multiprocessing import util
  from pickle import whichmodule, loads, dumps, HIGHEST_PROTOCOL, PicklingError
  from .numpy_pickle import dump, load, load_temporary_memmap
  from .backports import make_memmap
  from .disk import delete_folder
  from .externals.loky.backend import resource_tracker
label_desc: Use image node_id 4 for calling the ArrayMemmapForwardReducer obj's underlying member method code with example usage: obj.__call__(a) and returns: _reduce_memmap_backed, load_temporary_memmap,  filename,  self,  self, loads,  dumps