code: def compute_logq0_gnmax(sigma, order):
      """Computes the point where we start using data-independent bounds.
  
      Args:
        sigma: std of the Gaussian noise
        order: Renyi order lambda
  
      Returns:
        logq0: the point above which the data-ind bound overtakes data-dependent
        bound.
      """
  
      def _check_validity_conditions(logq):
          # Function returns true iff logq is in the range where data-dependent bound
          # is valid. (Theorem 6 in Appendix.)
          mu1, mu2 = _compute_mu1_mu2_gnmax(sigma, logq)
          if mu1 < order:
              return False
          eps2 = mu2 / sigma**2
          # Do computation in the log space. The condition below comes from Lemma 9
          # from Appendix.
          return logq <= (mu2 - 1) * eps2 - mu2 * math.log(
              mu1 / (mu1 - 1) * mu2 / (mu2 - 1)
          )
  
      def _compare_dep_vs_ind(logq):
          return _compute_data_dep_bound_gnmax(
              sigma, logq, order
          ) - pate.rdp_data_independent_gaussian(sigma, order)
  
      # Natural upper bounds on q0.
      logub = min(
          -((1 + 1.0 / sigma) ** 2),
          -(((order - 0.99) / sigma) ** 2),
          -1 / sigma**2,
      )
      assert _check_validity_conditions(logub)
  
      # If data-dependent bound is already better, we are done already.
      if _compare_dep_vs_ind(logub) < 0:
          return logub
  
      # Identifying a reasonable lower bound to bracket logq0.
      loglb = 2 * logub  # logub is negative, and thus loglb < logub.
      while _compare_dep_vs_ind(loglb) > 0:
          assert loglb > -10000, "The lower bound on q0 is way too low."
          loglb *= 1.5
  
      logq0, r = scipy.optimize.brentq(
          _compare_dep_vs_ind, loglb, logub, full_output=True
      )
      assert (
          r.converged
      ), "The root finding procedure failed to converge."
      assert _check_validity_conditions(logq0)  # just in case.
  
      return logq0
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import math
  from absl import app
  import numpy
  import scipy
  import sympy
  import core
label_desc: Use image node_id 6 for calling a global function with example usage: compute_logq0_gnmax(sigma, order) and returns: logq0, unknown, unknown, logub, False