class_docstr: Class for mapping a function to sequences.
  
  This will distribute the sequences according the a mapper, and call
  the function on each sub-sequence.  If called via map, then the function
  will be called once on each element, rather that each sub-sequence.
  
  Parameters
  ----------
  
  view : View instance
      The view to be used for execution
  f : callable
      The function to be wrapped into a remote function
  dist : str [default: 'b']
      The key for which mapObject to use to distribute sequences
      options are:
  
      * 'b' : use contiguous chunks in order
      * 'r' : use round-robin striping
  
  block : bool [default: None]
      Whether to wait for results or not.  The default behavior is
      to use the current `block` attribute of `view`
  chunksize : int or None
      The size of chunk to use when breaking up sequences in a load-balanced manner
  ordered : bool [default: True]
      Whether the result should be kept in order. If False,
      results become available as they arrive, regardless of submission order.
  return_exceptions : bool [default: False]
  **flags
      remaining kwargs are passed to View.temp_flags
class_docstr_tok: ["Class","for","mapping","a","function","to","sequences",".","This","will","distribute","the","sequences","according","the","a","mapper",",","and","call","the","function","on","each","sub-sequence",".","If","called","via","map",",","then","the","function","will","be","called","once","on","each","element",",","rather","that","each","sub-sequence",".","Parameters","--","--","--","--","--","view",":","View","instance","The","view","to","be","used","for","execution","f",":","callable","The","function","to","be","wrapped","into","a","remote","function","dist",":","str","[","default",":","'","b","'","]","The","key","for","which","mapObject","to","use","to","distribute","sequences","options","are",":","*","'","b","'",":","use","contiguous","chunks","in","order","*","'","r","'",":","use","round-robin","striping","block",":","bool","[","default",":","None","]","Whether","to","wait","for","results","or","not",".","The","default","behavior","is","to","use","the","current","`","block","`","attribute","of","`","view","`","chunksize",":","int","or","None","The","size","of","chunk","to","use","when","breaking","up","sequences","in","a","load-balanced","manner","ordered",":","bool","[","default",":","True","]","Whether","the","result","should","be","kept","in","order",".","If","False",",","results","become","available","as","they","arrive",",","regardless","of","submission","order",".","return_exceptions",":","bool","[","default",":","False","]","*","*","flags","remaining","kwargs","are","passed","to","View.temp_flags"]
code: def __call__(self, *sequences, **kwargs):
      global _prepickled_map
      if _prepickled_map is None:
          _prepickled_map = PrePickled(_map)
      client = self.view.client
      _mapping = kwargs.pop("__ipp_mapping", False)
      if kwargs:
          raise TypeError("Unexpected keyword arguments: %s" % kwargs)
  
      lens = []
      maxlen = minlen = -1
      for i, seq in enumerate(sequences):
          try:
              n = len(seq)
          except Exception:
              seq = list(seq)
              if isinstance(sequences, tuple):
                  # can't alter a tuple
                  sequences = list(sequences)
              sequences[i] = seq
              n = len(seq)
          if n > maxlen:
              maxlen = n
          if minlen == -1 or n < minlen:
              minlen = n
          lens.append(n)
  
      if maxlen == 0:
          # nothing to iterate over
          return []
  
      # check that the length of sequences match
      if not _mapping and minlen != maxlen:
          msg = (
              "all sequences must have equal length, but have %s" % lens
          )
          raise ValueError(msg)
  
      balanced = "Balanced" in self.view.__class__.__name__
      if balanced:
          if self.chunksize:
              nparts = maxlen // self.chunksize + int(
                  maxlen % self.chunksize > 0
              )
          else:
              nparts = maxlen
          targets = [None] * nparts
      else:
          if self.chunksize:
              warnings.warn(
                  "`chunksize` is ignored unless load balancing",
                  UserWarning,
              )
          # multiplexed:
          targets = self.view.targets
          # 'all' is lazily evaluated at execution time, which is now:
          if targets == "all":
              targets = client._build_targets(targets)[1]
          elif isinstance(targets, int):
              # single-engine view, targets must be iterable
              targets = [targets]
          nparts = len(targets)
  
      futures = []
  
      pf = PrePickled(self.func)
  
      chunk_sizes = {}
      chunk_size = 1
  
      for index, t in enumerate(targets):
          args = []
          for seq in sequences:
              part = self.mapObject.getPartition(
                  seq, index, nparts, maxlen
              )
              args.append(part)
  
          if sum(len(arg) for arg in args) == 0:
              continue
  
          if _mapping:
              chunk_size = min(len(arg) for arg in args)
  
          args = [PrePickled(arg) for arg in args]
  
          if _mapping:
              f = _prepickled_map
              args = [pf] + args
          else:
              f = pf
  
          view = self.view if balanced else client[t]
          with view.temp_flags(block=False, **self.flags):
              ar = view.apply(f, *args)
              ar.owner = False
  
          msg_id = ar.msg_ids[0]
          chunk_sizes[msg_id] = chunk_size
          futures.extend(ar._children)
  
      r = AsyncMapResult(
          self.view.client,
          futures,
          self.mapObject,
          fname=getname(self.func),
          ordered=self.ordered,
          return_exceptions=self.return_exceptions,
          chunk_sizes=chunk_sizes,
      )
  
      if self.block:
          try:
              return r.get()
          except KeyboardInterrupt:
              return r
      else:
          return r
  
file_path: ipyparallel/ipyparallel/client/remotefunction.py
imports: import sys
  import warnings
  from inspect import signature
  from decorator import decorator
  from ..serialize import PrePickled
  from .None import map
  from .asyncresult import AsyncMapResult
label_desc: Use image node_id 2 for calling the ParallelFunction obj's underlying member method code with example usage: obj.__call__() and returns: list, r, r, r