code: def test_simple_network(self):
      # From https://en.wikipedia.org/wiki/Bayesian_network#Example
      def model():
          raining = yield Root(
              bernoulli.Bernoulli(probs=0.2, dtype=tf.int32)
          )
          sprinkler_prob = [0.4, 0.01]
          sprinkler_prob = tf.gather(sprinkler_prob, raining)
          sprinkler = yield bernoulli.Bernoulli(
              probs=sprinkler_prob, dtype=tf.int32
          )
          grass_wet_prob = [[0.0, 0.8], [0.9, 0.99]]
          grass_wet_prob = tf.gather_nd(
              grass_wet_prob, _stack(sprinkler, raining)
          )
          grass_wet = yield bernoulli.Bernoulli(
              probs=grass_wet_prob, dtype=tf.int32
          )
  
      d = marginalize.MarginalizableJointDistributionCoroutine(model)
      # We want to know the probability that it was raining
      # and we want to marginalize over the state of the sprinkler.
      observations = [
          "tabulate",  # We want to know the probability it rained.
          "marginalize",  # We don't know the sprinkler state.
          1,
      ]  # We observed a wet lawn.
      p = tf.exp(d.marginalized_log_prob(observations))
      p = p / tf.reduce_sum(p)
      self.assertAllClose(p[1], 0.357688)
  
imports: import functools
  import itertools
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import bernoulli
  from tensorflow_probability.python.distributions import categorical
  from tensorflow_probability.python.distributions import deterministic
  from tensorflow_probability.python.distributions import hidden_markov_model
  from tensorflow_probability.python.distributions import joint_distribution_coroutine
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.distributions import poisson
  from tensorflow_probability.python.distributions import sample
  import tensorflow_probability.python.experimental.marginalize
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import test_util
label_desc: Use image node_id 3 for calling the _MarginalizeTest obj's underlying member method code with example usage: obj.test_simple_network() without return types