class_docstr: Reducer callable to dump large arrays to memmap files.
  
  Parameters
  ----------
  max_nbytes: int
      Threshold to trigger memmaping of large arrays to files created
      a folder.
  temp_folder: str
      Path of a folder where files for backing memmaped 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 memmaped 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","memmaping","of","large","arrays","to","files","created","a","folder",".","temp_folder",":","str","Path","of","a","folder","where","files","for","backing","memmaped","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","memmaped","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:
          # 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
  
          # Find a unique, concurrent safe filename for writing the
          # content of this array only once.
          basename = "%d-%d-%s.pkl" % (
              os.getpid(),
              id(threading.current_thread()),
              hash(a),
          )
          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
  
          # XXX: implement an explicit reference counting scheme to make it
          # possible to delete temporary files as soon as the workers are
          # done processing this data.
          if not os.path.exists(filename):
              if self.verbose > 0:
                  print(
                      "Memmaping (shape=%r, dtype=%s) to new file %s"
                      % (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 to avoid concurrent disk access in
                  # multiple children processes
                  load(filename, mmap_mode=self._mmap_mode).max()
          elif self.verbose > 1:
              print(
                  "Memmaping (shape=%s, dtype=%s) to old file %s"
                  % (a.shape, a.dtype, filename)
              )
  
          # The worker process will use joblib.load to memmap the data
          return (load, (filename, self._mmap_mode))
      else:
          # do not convert a into memmap, let pickler do its usual copy with
          # the default system pickler
          if self.verbose > 1:
              print(
                  "Pickling array (shape=%r, dtype=%s)."
                  % (a.shape, a.dtype)
              )
          return (loads, (dumps(a, protocol=HIGHEST_PROTOCOL),))
  
imports: from mmap import mmap
  import errno
  import os
  import stat
  import sys
  import threading
  import atexit
  import tempfile
  import shutil
  import warnings
  from time import sleep
  from pickle import whichmodule
  from pickle import Pickler
  from pickle import HIGHEST_PROTOCOL
  from io import BytesIO
  from ._multiprocessing_helpers import mp, assert_spawning
  from multiprocessing.pool import Pool
  from .numpy_pickle import load
  from .numpy_pickle import dump
  from .hashing import hash
label_desc: Use image node_id 2 for calling the ArrayMemmapReducer obj's underlying member method code with example usage: obj.__call__(a) and returns: _reduce_memmap_backed, load,  filename,  self, loads,  dumps