code: def test_logistic_regression(self):
      dim = 5
      n_objs = 10000
      np.random.seed(1)
      betas = np.random.randn(dim)  # The true beta
      intercept = np.random.randn()  # The true intercept
      features = np.random.randn(n_objs, dim)  # The feature matrix
      probs = 1 / (
          1
          + np.exp(
              -np.matmul(features, np.expand_dims(betas, -1))
              - intercept
          )
      )
      labels = np.random.binomial(1, probs)  # The true labels
      regularization = 0.8
      feat = tf.constant(features, dtype=tf.float64)
      lab = tf.constant(labels, dtype=feat.dtype)
  
      def f_negative_log_likelihood(params):
          intercept, beta = params[0], params[1:]
          logit = tf.matmul(feat, tf.expand_dims(beta, -1)) + intercept
          log_likelihood = tf.reduce_sum(
              tf.nn.sigmoid_cross_entropy_with_logits(
                  labels=lab, logits=logit
              )
          )
          l2_penalty = regularization * tf.reduce_sum(beta**2)
          total_loss = log_likelihood + l2_penalty
          return total_loss
  
      start_point = np.ones(dim + 1)
      argmin = [
          -2.38636155,
          1.61778325,
          -0.60694238,
          -0.51523609,
          -1.09832275,
          0.88892742,
      ]
  
      self._check_algorithm(
          func=f_negative_log_likelihood,
          start_point=start_point,
          expected_argmin=argmin,
          gtol=1e-5,
      )
  
imports: import numpy
  import tensorflow.compat.v2
  import tf_quant_finance
  from tensorflow.python.framework import test_util
label_desc: Use image node_id 5 for calling the ConjugateGradientTest obj's underlying member method code with example usage: obj.test_logistic_regression() and returns: total_loss