code: def _apply_dropout(inputs, time_major, hparams, training):
      """Applies dropout to the inputs.
  
      :attr:`inputs` is a Tensor of shape `[batch_size, max_time, dim]`
      if :attr:`time_major=False`, or shape `[max_time, batch_size, dim]`
      if :attr:`time_major=True`.
      """
      noise_shape = None
      if hparams.variational_dropout:
          if time_major:
              noise_shape = [1, None, None]
          else:
              noise_shape = [None, 1, None]
      return tf.layers.dropout(
          inputs,
          rate=hparams.dropout_rate,
          noise_shape=noise_shape,
          training=training,
      )
  
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 4 for calling a global function with example usage: _apply_dropout(inputs, time_major, hparams, training) and returns: tf