code: def compute_logq_gaussian(counts, sigma):
      """Returns an upper bound on ln Pr[outcome != argmax] for GNMax.
  
      Implementation of Proposition 7.
  
      Args:
        counts: A numpy array of scores.
        sigma: The standard deviation of the Gaussian noise in the GNMax mechanism.
  
      Returns:
        logq: Natural log of the probability that outcome is different from argmax.
      """
      n = len(counts)
      variance = sigma**2
      idx_max = np.argmax(counts)
      counts_normalized = counts[idx_max] - counts
      counts_rest = counts_normalized[
          np.arange(n) != idx_max
      ]  # exclude one index
      # Upper bound q via a union bound rather than a more precise calculation.
      logq = _logaddexp(
          scipy.stats.norm.logsf(
              counts_rest, scale=math.sqrt(2 * variance)
          )
      )
  
      # A sketch of a more accurate estimate, which is currently disabled for two
      # reasons:
      # 1. Numerical instability;
      # 2. Not covered by smooth sensitivity analysis.
      # covariance = variance * (np.ones((n - 1, n - 1)) + np.identity(n - 1))
      # logq = np.log1p(-statsmodels.sandbox.distributions.extras.mvnormcdf(
      #     counts_rest, np.zeros(n - 1), covariance, maxpts=1e4))
  
      return min(logq, math.log(1 - (1 / n)))
  
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.stats
label_desc: Use image node_id 4 for calling a global function with example usage: compute_logq_gaussian(counts, sigma) and returns: min