class_docstr: Helper class for creating sets of parallel function calls.
  
  The purpose of this class is to replace this code:
  
      e = []
      f = []
      for i in range(len(devices)):
        with tf.device(devices[i]):
          e_, f_ = func(a[i], b[i], c)
          e.append(e_)
          f.append(f_)
  
  with this code:
  
      e, f = expert_utils.Parallelism(devices)(func, a, b, c)
class_docstr_tok: ["Helper","class","for","creating","sets","of","parallel","function","calls",".","The","purpose","of","this","class","is","to","replace","this","code",":","e","=","[","]","f","=","[","]","for","i","in","range","(","len","(","devices",")",")",":","with","tf.device","(","devices","[","i","]",")",":","e_",",","f_","=","func","(","a","[","i","]",",","b","[","i","]",",","c",")","e.append","(","e_",")","f.append","(","f_",")","with","this","code",":","e",",","f","=","expert_utils.Parallelism","(","devices",")","(","func",",","a",",","b",",","c",")"]
docstr: Create a Parallelism.
  
  Args:
    device_names_or_functions: A list of length n, containing device names
      or device functions (see `tf.device`)
    reuse: True or None.  Whether to reuse variables created in the first
      replica in the subsequent replicas.
    caching_devices: Either `None`, or a list of length n containing device
      names.
    daisy_chain_variables: a boolean - if true, then copies variables in a
      daisy chain between devices.
    ps_devices: list<str>, list of devices for experts.
  
  Returns:
    a Parallelism.
docstr_tok: ["Create","a","Parallelism",".","Args",":","device_names_or_functions",":","A","list","of","length","n",",","containing","device","names","or","device","functions","(","see","`","tf.device","`",")","reuse",":","True","or","None",".","Whether","to","reuse","variables","created","in","the","first","replica","in","the","subsequent","replicas",".","caching_devices",":","Either","`","None","`",",","or","a","list","of","length","n","containing","device","names",".","daisy_chain_variables",":","a","boolean","-","if","true",",","then","copies","variables","in","a","daisy","chain","between","devices",".","ps_devices",":","list","<","str",">",",","list","of","devices","for","experts",".","Returns",":","a","Parallelism","."]
code: def __init__(
      self,
      device_names_or_functions,
      reuse=True,
      caching_devices=None,
      daisy_chain_variables=False,
      ps_devices=None,
  ):
      """Create a Parallelism.
  
      Args:
        device_names_or_functions: A list of length n, containing device names
          or device functions (see `tf.device`)
        reuse: True or None.  Whether to reuse variables created in the first
          replica in the subsequent replicas.
        caching_devices: Either `None`, or a list of length n containing device
          names.
        daisy_chain_variables: a boolean - if true, then copies variables in a
          daisy chain between devices.
        ps_devices: list<str>, list of devices for experts.
  
      Returns:
        a Parallelism.
      """
      assert device_names_or_functions
      self._devices = device_names_or_functions
      self._n = len(device_names_or_functions)
      self._reuse = reuse
      self._caching_devices = self._maybe_repeat(caching_devices)
      self._daisy_chain_variables = daisy_chain_variables
      self._ps_devices = ps_devices or [""]
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import functools
  import math
  import six
  from six.moves import range
  from six.moves import zip
  from tensor2tensor.layers import common_layers
  from tensor2tensor.layers.vq_discrete import DiscreteBottleneck
  import tensorflow.compat.v1
label_desc: Use image node_id 1 to create a new Parallelism object from inherited base classes: object with example: obj = Parallelism(device_names_or_functions, reuse, caching_devices, daisy_chain_variables, ps_devices)