code: def testNumIter(self):
      # Same as testL2Regularization, except we set
      # maximum_full_sweeps_per_iteration = 1 and check that the number of sweeps
      # is equals what we expect it to (usually we don't know the exact number,
      # but in this simple case we do -- explanation below).
      #
      # Since l1_regularizer = 0, the soft threshold operator is actually the
      # identity operator, hence the `minimize` algorithm
      # becomes literally coordinatewise Newton's method being used to find the
      # zeros of grad Loss(x), which in this case is a linear function of x. Hence
      # Newton's method should find the exact correct answer in 1 sweep.  At the
      # end of the first sweep the algorithm does not yet know it has converged;
      # it takes a second sweep, when the algorithm notices that its answer hasn't
      # changed at all, to become aware that convergence has happened.  Hence we
      # expect two sweeps.  So with maximum_full_sweeps_per_iteration = 1, that
      # means we expect 2 iterations of the outer loop.
      n = 100
      np.random.seed(42)
      a_ = np.random.random(size=(n,))
      a = self._adjust_dtype_and_shape_hints(a_)
  
      def _grad_and_hessian_unregularized_loss_fn(x):
          grad = 2 * (x - a)
          hessian_outer = tf.linalg.tensor_diag(tf.ones_like(a))
          hessian_middle = 2.0 * tf.ones_like(a)
          return grad, hessian_outer, hessian_middle
  
      w, is_converged, num_iter = proximal_hessian_sparse.minimize(
          _grad_and_hessian_unregularized_loss_fn,
          x_start=tf.zeros_like(a_, dtype=self.dtype),
          l1_regularizer=0.0,
          l2_regularizer=1.0,
          maximum_iterations=4,
          maximum_full_sweeps_per_iteration=1,
          tolerance=1e-5,
          learning_rate=1.0,
      )
  
      w_, is_converged_, num_iter_ = self.evaluate(
          [w, is_converged, num_iter]
      )
  
      expected_w = 0.5 * a
      self.assertAllEqual(is_converged_, True)
      self.assertAllEqual(num_iter_, 2)
      self.assertAllClose(w_, expected_w, atol=0.0, rtol=0.03)
  
imports: import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.optimizer import proximal_hessian_sparse
label_desc: Use image node_id 8 for calling the _ProximalHessianTest obj's underlying member method code with example usage: obj.testNumIter() and returns: grad,  hessian_outer,  hessian_middle