code: def _forward_output_layers(
      inputs,
      input_size,
      output_layer,
      time_major,
      hparams,
      mode,
      sequence_length=None,
  ):
      """Forwards inputs through the output layers.
  
      Args:
          inputs: A Tensor of shape `[batch_size, max_time] + input_size` if
              :attr:`time_major=False`, or shape
              `[max_time, batch_size] + input_size` if :attr:`time_major=True`.
  
      Returns:
          A pair :attr:`(outputs, outputs_size), where
  
          - :attr:`outputs`: A Tensor of shape \
            `[batch_size, max_time] + outputs_size`.
  
          - :attr:`outputs_size`: An `int` or 1D `int` array representing the \
            output size.
      """
      if output_layer is None:
          return inputs, input_size
  
      if hparams is None:
          # output_layer was passed in from the constructor
          if isinstance(output_layer, (list, tuple)):
              raise ValueError(
                  "output_layer must not be a list or tuple."
              )
          output, output_size = _forward_single_output_layer(
              inputs, input_size, output_layer
          )
      else:
          # output_layer was built based on hparams
          output_layer = _to_list(output_layer)
  
          dropout_layer_ids = _to_list(hparams.dropout_layer_ids)
          if len(dropout_layer_ids) > 0:
              training = is_train_mode(mode)
  
          output = inputs
          output_size = input_size
          for i, layer in enumerate(output_layer):
              if i in dropout_layer_ids:
                  output = _apply_dropout(
                      output, time_major, hparams, training
                  )
              output, output_size = _forward_single_output_layer(
                  output, output_size, layer
              )
  
          if len(output_layer) in dropout_layer_ids:
              output = _apply_dropout(
                  output, time_major, hparams, training
              )
  
      if sequence_length is not None:
          output = mask_sequences(
              output,
              sequence_length,
              time_major=time_major,
              tensor_rank=3,
          )
  
      return output, output_size
  
imports: import functools
  import numpy
  import tensorflow
  from tensorflow.contrib.framework import nest
  from texar.tf.modules.encoders.encoder_base import EncoderBase
  from texar.tf.modules.networks.conv_networks import _to_list
  from texar.tf.core import layers
  from texar.tf.utils.mode import is_train_mode
  from texar.tf.utils.shapes import mask_sequences
  from texar.tf.hyperparams import HParams
label_desc: Use image node_id 5 for calling a global function with example usage: _forward_output_layers(inputs, input_size, output_layer, time_major, hparams, mode, sequence_length) and returns: output,  output_size, inputs,  input_size