code: def test_dropout_rate(self, rate):
      mod = dropout.Dropout(rate=rate)
      x = tf.ones([1000])
      x = mod(x, is_training=True)
  
      # We should have dropped something, test we're within 10% of rate.
      # (or 30% on a TPU)
      rtol = 0.3 if "TPU" in self.device_types else 0.1
      kept = tf.math.count_nonzero(x).numpy()
      keep_prob = 1 - rate
      self.assertAllClose(kept, 1000 * keep_prob, rtol=rtol)
  
file_path: sonnet/sonnet/src/dropout_test.py
imports: from absl.testing import parameterized
  import numpy
  from sonnet.src import dropout
  from sonnet.src import test_utils
  import tensorflow
label_desc: Use image node_id 2 for calling the DropoutTest obj's underlying member method code with example usage: obj.test_dropout_rate(rate) without return types