code: def _test_fit_glm_from_data(
      self, n, d, link, model, batch_shape=None, use_sparse_tensor=False
  ):
      if batch_shape is None:
          batch_shape = []
      # Create synthetic data according to the given `link` function.
      (
          model_matrix_,
          response_,
          model_coefficients_true_,
          _,
      ) = self._make_dataset(
          n=n, d=d, link=link, batch_shape=batch_shape
      )
  
      # Run tfp.glm.fit_sparse on the synthetic data for the given model.
      # Also adjust dtype and shape hints depending on the test mode.
      (
          model_matrix,
          response,
          model_coefficients_start,
      ) = self._prepare_inputs_for_fit_sparse(
          model_matrix_,
          response_,
          convert_to_sparse_tensor=use_sparse_tensor,
      )
  
      def has_xla():
          try:
              tf.function(lambda: tf.constant(0), jit_compile=True)()
              return True
          except (
              tf.errors.UnimplementedError,
              NotImplementedError,
              ValueError,
          ):
              return False
  
      # We need to ensure `fit_sparse` works with XLA. Note:
      # - In eager mode test regime, this `tf.function` will be ignored.
      # - Many sparse ops are not supported by XLA so we can't and don't test this
      #   use case.
      compile_with_xla = has_xla() and not use_sparse_tensor
  
      @tf.function(autograph=False, jit_compile=compile_with_xla)
      def run():
          (
              model_coefficients,
              is_converged,
              _,
          ) = proximal_hessian.fit_sparse(
              model_matrix,
              response,
              model,
              model_coefficients_start,
              l1_regularizer=800.0,
              l2_regularizer=None,
              maximum_iterations=10,
              maximum_full_sweeps_per_iteration=10,
              tolerance=1e-6,
              learning_rate=None,
          )
          return model_coefficients, is_converged
  
      model_coefficients_, is_converged_ = self.evaluate(run())
  
      # Ensure that we have converged and learned coefficients are close to the
      # true coefficients.
      self.assertAllEqual(is_converged_, True)
      self.assertAllClose(
          model_coefficients_,
          model_coefficients_true_,
          atol=0.2,
          rtol=0.2,
      )
  
imports: import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import bernoulli
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.distributions import uniform
  from tensorflow_probability.python.glm import family
  from tensorflow_probability.python.glm import proximal_hessian
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math import sparse
label_desc: Use image node_id 6 for calling the _ProximalHessianTest obj's underlying member method code with example usage: obj._test_fit_glm_from_data(n, d, link, model, batch_shape, use_sparse_tensor) and returns: model_coefficients,  is_converged, True, False