code: def test_fitting_example(self):
      build_trainable_normal = trainable_state_util.as_stateful_builder(
          normal_generator
      )
      trainable_dist = build_trainable_normal(
          shape=[], seed=test_util.test_seed(sampler_type="stateless")
      )
      optimizer = tf_keras.optimizers.Adam(1.0)
      # Find the maximum likelihood distribution given observed data.
      x_observed = [3.0, -2.0, 1.7]
      losses = minimize(
          loss_fn=lambda: -trainable_dist.log_prob(x_observed),
          optimizer=optimizer,
          num_steps=300,
      )
      self.evaluate(tf1.global_variables_initializer())
      losses = self.evaluate(losses)
      self.assertAllClose(
          trainable_dist.mean(), np.mean(x_observed), atol=0.1
      )
      self.assertAllClose(
          trainable_dist.stddev(), np.std(x_observed), atol=0.1
      )
  
imports: import functools
  from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import identity
  from tensorflow_probability.python.bijectors import joint_map
  from tensorflow_probability.python.bijectors import softplus
  from tensorflow_probability.python.distributions import deterministic
  from tensorflow_probability.python.distributions import joint_distribution_auto_batched
  from tensorflow_probability.python.distributions import joint_distribution_sequential
  from tensorflow_probability.python.distributions import lognormal
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.internal import tf_keras
  from tensorflow_probability.python.internal import trainable_state_util
  from tensorflow_probability.python.math import gradient
  from tensorflow_probability.python.math.minimize import minimize
  from tensorflow_probability.python.math.minimize import minimize_stateless
label_desc: Use image node_id 4 for calling the TestWrapGeneratorAsStateful obj's underlying member method code with example usage: obj.test_fitting_example() without return types