code: def test_obeys_convergence_criterion(self):
      init_x = np.array([0.0, 0.0]).astype(np.float32)
      target_x = np.array([3.0, 4.0]).astype(np.float32)
  
      loss_fn = lambda x: tf.reduce_sum((x - target_x) ** 2)
  
      # Check that we can trace the convergence criterion's moving average of
      # decrease in loss.
      trace_fn = lambda tq: (  # pylint: disable=g-long-lambda
          tq.loss,
          tq.convergence_criterion_state.average_decrease_in_loss,
      )
      atol = 0.1
      _, (losses, moving_average_decreases) = self.evaluate(
          minimize_stateless(
              loss_fn,
              init=init_x,
              num_steps=100,
              optimizer=StatelessSGD(0.1),
              convergence_criterion=(
                  optimizer.convergence_criteria.LossNotDecreasing(
                      atol=atol
                  )
              ),
              trace_fn=trace_fn,
              return_full_length_trace=False,
          )
      )
      self.assertLess(moving_average_decreases[-1], atol)
      self.assertGreater(moving_average_decreases[-3], atol)
      self.assertAllEqual(losses.shape, [35])
  
      # Check that the second-step loss decreases from the first step. This could
      # fail in graph mode if we were sloppy with `control_dependencies`, so that
      # the steps ran simultaneously or in the wrong order.
      self.assertGreater(losses[0] - losses[1], 1e-4)
  
imports: import collections
  import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python import optimizer
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.internal import tf_keras
  from tensorflow_probability.python.math.minimize import minimize
  from tensorflow_probability.python.math.minimize import minimize_stateless
label_desc: Use image node_id 10 for calling the MinimizeStatelessTests obj's underlying member method code with example usage: obj.test_obeys_convergence_criterion() without return types