code: def dropout(x, rate, noise_shape=None, seed=None, name=None):
      """DTensor replacement for dropout."""
      if not isinstance(rate, float):
          raise ValueError("rate should be float for dropout.")
      if seed is None:
          raise ValueError(
              "seed must be specified for DTensor dropout. Got: None"
          )
  
      with ops.name_scope(name, "dropout", [x]):
          x_dtype = x.dtype
          keep_prob = 1 - rate
          scale = 1 / keep_prob
          scale = ops.convert_to_tensor(scale, dtype=x_dtype)
          ret = gen_math_ops.mul(x, scale)
  
          noise_shape = _get_noise_shape(x, noise_shape)
          # stateless_random_uniform requires a shape [2] seed.
          seed = [seed, 0]
  
          if context.executing_eagerly():
              layout = api.fetch_layout(x)
          else:
              layout = None
          random_tensor = _old_tf_random_stateless_uniform(
              noise_shape,
              seed=seed,
              minval=0,
              maxval=1,
              dtype=x_dtype,
              layout=layout,
          )
          keep_mask = random_tensor >= rate
          ret = gen_math_ops.mul(
              ret, gen_math_ops.cast(keep_mask, x_dtype)
          )
          if not context.executing_eagerly():
              ret.set_shape(x.get_shape())
          return ret
  
file_path: tensorflow/tensorflow/dtensor/python/d_random.py
imports: from tensorflow.dtensor.python import api
  from tensorflow.dtensor.python import layout
  from tensorflow.python.eager import context
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import gen_math_ops
  from tensorflow.python.ops import gen_stateless_random_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import shape_util
label_desc: Use image node_id 9 for calling a global function with example usage: dropout(x, rate, noise_shape, seed, name) and returns: ret