code: def Dropout(x, *args, **kwargs):
      """
      Same as `tf.layers.dropout`.
      However, for historical reasons, the first positional argument is
      interpreted as keep_prob rather than drop_prob.
      Explicitly use `rate=` keyword arguments to ensure things are consistent.
      """
      if "is_training" in kwargs:
          kwargs["training"] = kwargs.pop("is_training")
      if len(args) > 0:
          if args[0] != 0.5:
              logger.warn(
                  "The first positional argument to tensorpack.Dropout is the probability to keep, rather than to drop. "
                  "This is different from the rate argument in tf.layers.Dropout due to historical reasons. "
                  "To mimic tf.layers.Dropout, explicitly use keyword argument 'rate' instead"
              )
          rate = 1 - args[0]
      elif "keep_prob" in kwargs:
          assert (
              "rate" not in kwargs
          ), "Cannot set both keep_prob and rate!"
          rate = 1 - kwargs.pop("keep_prob")
      elif "rate" in kwargs:
          rate = kwargs.pop("rate")
      else:
          rate = 0.5
  
      if kwargs.get("training", None) is None:
          kwargs["training"] = get_current_tower_context().is_training
  
      if get_tf_version_tuple() <= (1, 12):
          return tf.layers.dropout(x, rate=rate, **kwargs)
      else:
          return tf.nn.dropout(
              x, rate=rate if kwargs["training"] else 0.0
          )
  
file_path: tensorpack/tensorpack/models/regularize.py
imports: import re
  import tensorflow
  from ..compat import tfv1
  from ..tfutils.common import get_tf_version_tuple
  from ..tfutils.tower import get_current_tower_context
  from ..utils import logger
  from ..utils.argtools import graph_memoized
  from .common import layer_register
label_desc: Use image node_id 4 for calling a global function with example usage: Dropout(x) and returns: tf, tf