code: def _build_dense_output_layer(hparams):
      nlayers = hparams.num_layers
  
      if nlayers <= 0:
          return None
  
      layer_size = _to_list(
          hparams.layer_size, "output_layer.layer_size", nlayers
      )
  
      other_kwargs = hparams.other_dense_kwargs or {}
      if isinstance(other_kwargs, HParams):
          other_kwargs = other_kwargs.todict()
      if not isinstance(other_kwargs, dict):
          raise ValueError(
              "hparams 'output_layer.other_dense_kwargs' must be a dict."
          )
  
      dense_layers = []
      for i in range(nlayers):
          if i == nlayers - 1:
              activation = hparams.final_layer_activation
          else:
              activation = hparams.activation
  
          kwargs_i = {
              "units": layer_size[i],
              "activation": activation,
              "name": "dense_%d" % (i + 1),
          }
          kwargs_i.update(other_kwargs)
  
          layer_hparams = {"type": "Dense", "kwargs": kwargs_i}
          dense_layers.append(layers.get_layer(hparams=layer_hparams))
  
      if len(dense_layers) == 1:
          dense_layers = dense_layers[0]
  
      return dense_layers
  
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 2 for calling a global function with example usage: _build_dense_output_layer(hparams) and returns: dense_layers, None