def get_dropout(x, rate=0.0, init=True):
  """Dropout x with dropout_rate = rate.

  Apply zero dropout during init or prediction time.

  Args:
    x: 4-D Tensor, shape=(NHWC).
    rate: Dropout rate.
    init: Initialization.
  Returns:
    x: activations after dropout.
  """
  if init or rate == 0:
    return x
  return tf.layers.dropout(x, rate=rate, training=True)