class_docstr: A stack of layers for Universal Transformer.
  
  This implementation is largely adapted from t2t universal transformer
  implementation. Reference:
  third_party/py/tensor2tensor/models/research
class_docstr_tok: ["A","stack","of","layers","for","Universal","Transformer",".","This","implementation","is","largely","adapted","from","t2t","universal","transformer","implementation",".","Reference",":","third_party\/py\/tensor2tensor\/models\/research"]
docstr: Implements a Feed-forward layer with multiple inputs, pad-removing, etc.
  
  Args:
    context: mtf context
    mask: mask
    inputs_list: list of input tensors
    ffn_layer_type: dense / dense_dropconnect/ dense_relu_dense
    kernel_initializer: kernel initializer
    activation: activation function
    preprocess: if preprocess the input --> default: layer-norm
    postprocess: if postprocess the output --> default: drop-out and residual
  
  Returns:
    a tensor
  Raises:
    ValueError: Unknown ffn_layer type.
docstr_tok: ["Implements","a","Feed-forward","layer","with","multiple","inputs",",","pad-removing",",","etc",".","Args",":","context",":","mtf","context","mask",":","mask","inputs_list",":","list","of","input","tensors","ffn_layer_type",":","dense","\/","dense_dropconnect\/","dense_relu_dense","kernel_initializer",":","kernel","initializer","activation",":","activation","function","preprocess",":","if","preprocess","the","input","--",">","default",":","layer-norm","postprocess",":","if","postprocess","the","output","--",">","default",":","drop-out","and","residual","Returns",":","a","tensor","Raises",":","ValueError",":","Unknown","ffn_layer","type","."]
code: def ffn_layer_multi_inputs(
      self,
      context,
      mask,
      inputs_list,
      ffn_layer_type="dense",
      kernel_initializer=None,
      activation=None,
      preprocess=False,
      postprocess=False,
  ):
      """Implements a Feed-forward layer with multiple inputs, pad-removing, etc.
  
      Args:
        context: mtf context
        mask: mask
        inputs_list: list of input tensors
        ffn_layer_type: dense / dense_dropconnect/ dense_relu_dense
        kernel_initializer: kernel initializer
        activation: activation function
        preprocess: if preprocess the input --> default: layer-norm
        postprocess: if postprocess the output --> default: drop-out and residual
  
      Returns:
        a tensor
      Raises:
        ValueError: Unknown ffn_layer type.
  
      """
  
      # need at least one inputs
      num_inputs = len(inputs_list)
      assert num_inputs > 0
  
      if preprocess:
          # In case of having more than one input to the ffn,
          # we just apply layer norm on them independently as preprocessing
          for i, inputs in enumerate(inputs_list):
              inputs_list[i] = self._layer_norm(
                  context, (inputs * mask) if mask else inputs
              )
  
      # the output size is the hidden size of the main inputs
      ffn_inputs = inputs_list[0]
      if len(inputs_list) != 1:
          ffn_inputs = mtf.concat(
              inputs_list, context.model.model_dim.name
          )
      if ffn_layer_type == "dense":
          # last_dims = [
          #     mtf.Dimension(ffn_inputs.shape.dims[-1].name, hidden_size)
          # ]
          output = mtf.layers.dense(
              ffn_inputs,
              reduced_dims=[ffn_inputs.shape.dims[-1]],
              new_dims=[context.model.model_dim],
              activation=activation,
              use_bias=True,
              variable_dtype=context.variable_dtype,
              expert_dims=context.model.ensemble_dims,
              kernel_initializer=kernel_initializer,
          )
      elif ffn_layer_type == "dense_relu_dense":
          output = mtf.layers.dense_relu_dense(
              ffn_inputs,
              hidden_channels=context.model.model_dim,
              is_training=context.train,
              dropout=self.relu_dropout,
          )
  
      else:
          raise ValueError(
              "Unknown ffn_layer type: %s" % ffn_layer_type
          )
  
      if postprocess:
          output = self._layer_norm(
              context, (output * mask) if mask else output
          )
  
      return output
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import math
  import gin
  import mesh_tensorflow
  from mesh_tensorflow.transformer import transformer
  import tensorflow.compat.v1
label_desc: Use image node_id 11 for calling the UTLayerStack obj's underlying member method code with example usage: obj.ffn_layer_multi_inputs(context, mask, inputs_list, ffn_layer_type, kernel_initializer, activation, preprocess, postprocess) and returns: output