code: def test_expected_value(self):
      shape_ = np.array([2, int(1e3)], np.int32)
      shape = (
          tf.constant(shape_)
          if self.use_static_shape
          else tf1.placeholder_with_default(shape_, shape=None)
      )
      # This shape will require broadcasting before sampling.
      scale_ = (
          np.linspace(0.1, 0.5, 3 * 2).astype(self.dtype).reshape(3, 2)
      )
      scale = (
          tf.constant(scale_)
          if self.use_static_shape
          else tf1.placeholder_with_default(scale_, shape=None)
      )
      x = random_ops.rayleigh(
          shape,
          scale=scale[..., tf.newaxis],
          dtype=self.dtype,
          seed=test_util.test_seed(),
      )
      self.assertEqual(self.dtype, dtype_util.as_numpy_dtype(x.dtype))
      final_shape_ = [3, 2, int(1e3)]
      if self.use_static_shape:
          self.assertAllEqual(final_shape_, x.shape)
      sample_mean = tf.reduce_mean(x, axis=-1, keepdims=True)
      sample_var = tf.reduce_mean(
          tf.math.squared_difference(x, sample_mean), axis=-1
      )
      [x_, sample_var_] = self.evaluate([x, sample_var])
      self.assertAllEqual(final_shape_, x_.shape)
      self.assertAllEqual(np.ones_like(x_, dtype=np.bool_), x_ > 0.0)
      self.assertAllMeansClose(
          x_,
          np.sqrt(np.pi / 2.0) * scale_,
          axis=-1,
          atol=0.05,
          rtol=0.0,
      )
      self.assertAllClose(
          0.5 * (4.0 - np.pi) * scale_**2.0,
          sample_var_,
          atol=0.05,
          rtol=0.0,
      )
  
imports: import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.random import random_ops
  from tensorflow_probability.python.stats import sample_stats
label_desc: Use image node_id 1 for calling the _RandomRayleigh obj's underlying member method code with example usage: obj.test_expected_value() without return types