def random_rademacher(shape, dtype=tf.float32, seed=None, name=None):
with tf.compat.v1.name_scope(name, '<STR_LIT>', [shape, seed]):<EOL><INDENT>generation_dtype = tf.int64 if tf.as_dtype(dtype) != tf.int32 else tf.int32<EOL>random_bernoulli = tf.random.uniform(<EOL>shape, minval=<NUM_LIT:0>, maxval=<NUM_LIT:2>, dtype=generation_dtype, seed=seed)<EOL>return tf.cast(<NUM_LIT:2> * random_bernoulli - <NUM_LIT:1>, dtype)<EOL><DEDENT>
Generates `Tensor` consisting of `-1` or `+1`, chosen uniformly at random.

    For more details, see [Rademacher distribution](
    https://en.wikipedia.org/wiki/Rademacher_distribution).

    Args:
      shape: Vector-shaped, `int` `Tensor` representing shape of output.
      dtype: (Optional) TF `dtype` representing `dtype` of output.
      seed: (Optional) Python integer to seed the random number generator.
      name: Python `str` name prefixed to Ops created by this function.
        Default value: `None` (i.e., 'random_rademacher').

    Returns:
      rademacher: `Tensor` with specified `shape` and `dtype` consisting of `-1`
        or `+1` chosen uniformly-at-random.