class_docstr: A subclass of :tf_main:`tf.layers.Layer <layers/Layer>`.
  A layer that consists of multiple layers in parallel. Input is fed to
  each of the parallel layers, and the outputs are merged with a
  specified mode.
  
  Args:
      layers (list, optional): A list of :tf_main:`tf.layers.Layer
          <layers/layer>` instances, or a list of hyperparameter dicts
          each of which specifies type and kwargs of each layer (see
          the `hparams` argument of :func:`get_layer`).
  
          If `None`, this layer degenerates to a merging operator that merges
          inputs directly.
      mode (str): Mode of the merge op. This can be:
  
          - :attr:`'concat'`: Concatenates layer outputs along one axis.               Tensors must have the same shape except for the dimension               specified in `axis`, which can have different sizes.
          - :attr:`'elemwise_sum'`: Outputs element-wise sum.
          - :attr:`'elemwise_mul'`: Outputs element-wise product.
          - :attr:`'sum'`: Computes the sum of layer outputs along the               dimension given by `axis`. E.g., given `axis=1`,               two tensors of shape `[a, b]` and `[a, c]` respectively               will result in a merged tensor of shape `[a]`.
          - :attr:`'mean'`: Computes the mean of layer outputs along the               dimension given in `axis`.
          - :attr:`'prod'`: Computes the product of layer outputs along the               dimension given in `axis`.
          - :attr:`'max'`: Computes the maximum of layer outputs along the               dimension given in `axis`.
          - :attr:`'min'`: Computes the minimum of layer outputs along the               dimension given in `axis`.
          - :attr:`'and'`: Computes the `logical and` of layer outputs along               the dimension given in `axis`.
          - :attr:`'or'`: Computes the `logical or` of layer outputs along               the dimension given in `axis`.
          - :attr:`'logsumexp'`: Computes               log(sum(exp(elements across the dimension of layer outputs)))
      axis (int): The axis to use in merging. Ignored in modes
          :attr:`'elemwise_sum'` and :attr:`'elemwise_mul'`.
      trainable (bool): Whether the layer should be trained.
      name (str, optional): Name of the layer.
class_docstr_tok: ["A","subclass","of",":","tf_main",":","`","tf.layers.Layer","<","layers\/Layer",">","`",".","A","layer","that","consists","of","multiple","layers","in","parallel",".","Input","is","fed","to","each","of","the","parallel","layers",",","and","the","outputs","are","merged","with","a","specified","mode",".","Args",":","layers","(","list",",","optional",")",":","A","list","of",":","tf_main",":","`","tf.layers.Layer","<","layers\/layer",">","`","instances",",","or","a","list","of","hyperparameter","dicts","each","of","which","specifies","type","and","kwargs","of","each","layer","(","see","the","`","hparams","`","argument","of",":","func",":","`","get_layer","`",")",".","If","`","None","`",",","this","layer","degenerates","to","a","merging","operator","that","merges","inputs","directly",".","mode","(","str",")",":","Mode","of","the","merge","op",".","This","can","be",":","-",":","attr",":","`","'concat","'","`",":","Concatenates","layer","outputs","along","one","axis",".","Tensors","must","have","the","same","shape","except","for","the","dimension","specified","in","`","axis","`",",","which","can","have","different","sizes",".","-",":","attr",":","`","'elemwise_sum","'","`",":","Outputs","element-wise","sum",".","-",":","attr",":","`","'elemwise_mul","'","`",":","Outputs","element-wise","product",".","-",":","attr",":","`","'sum","'","`",":","Computes","the","sum","of","layer","outputs","along","the","dimension","given","by","`","axis","`",".","E.g.",",","given","`","axis=1","`",",","two","tensors","of","shape","`","[","a",",","b","]","`","and","`","[","a",",","c","]","`","respectively","will","result","in","a","merged","tensor","of","shape","`","[","a","]","`",".","-",":","attr",":","`","'mean","'","`",":","Computes","the","mean","of","layer","outputs","along","the","dimension","given","in","`","axis","`",".","-",":","attr",":","`","'prod","'","`",":","Computes","the","product","of","layer","outputs","along","the","dimension","given","in","`","axis","`",".","-",":","attr",":","`","'max","'","`",":","Computes","the","maximum","of","layer","outputs","along","the","dimension","given","in","`","axis","`",".","-",":","attr",":","`","'min","'","`",":","Computes","the","minimum","of","layer","outputs","along","the","dimension","given","in","`","axis","`",".","-",":","attr",":","`","'and","'","`",":","Computes","the","`","logical","and","`","of","layer","outputs","along","the","dimension","given","in","`","axis","`",".","-",":","attr",":","`","'or","'","`",":","Computes","the","`","logical","or","`","of","layer","outputs","along","the","dimension","given","in","`","axis","`",".","-",":","attr",":","`","'logsumexp","'","`",":","Computes","log","(","sum","(","exp","(","elements","across","the","dimension","of","layer","outputs",")",")",")","axis","(","int",")",":","The","axis","to","use","in","merging",".","Ignored","in","modes",":","attr",":","`","'elemwise_sum","'","`","and",":","attr",":","`","'elemwise_mul","'","`",".","trainable","(","bool",")",":","Whether","the","layer","should","be","trained",".","name","(","str",",","optional",")",":","Name","of","the","layer","."]
code: def __init__(
      self,
      layers=None,
      mode="concat",
      axis=1,
      trainable=True,
      name=None,
      **kwargs,
  ):
      super(MergeLayer, self).__init__(
          trainable=trainable, name=name, **kwargs
      )
      self._mode = mode
      self._axis = axis
  
      self._layers = None
      if layers is not None:
          if len(layers) == 0:
              raise ValueError(
                  "'layers' must be either None or a non-empty list."
              )
          self._layers = []
          for layer in layers:
              if isinstance(layer, tf.layers.Layer):
                  self._layers.append(layer)
              else:
                  self._layers.append(get_layer(hparams=layer))
  
      # Keep tracks of whether trainable variables have been created
      self._vars_built = False
  
imports: import copy
  import tensorflow
  import tensorflow.contrib.rnn
  from texar.tf.hyperparams import HParams
  from texar.tf.utils import utils
  from texar.tf.utils.dtypes import is_str
  from texar.tf.utils.variables import add_variable
  from texar.tf.utils.mode import is_train_mode, switch_dropout
label_desc: Use image node_id 1 to create a new MergeLayer object from inherited base classes: tf.layers with example: obj = MergeLayer(layers, mode, axis, trainable, name)