code: def compute_logq_laplace(counts, lmbd):
      """Computes an upper bound on log Pr[outcome != argmax] for LNMax.
  
      Args:
        counts: A list of scores.
        lmbd: The lambda parameter of the Laplace distribution ~exp(-|x| / lambda).
  
      Returns:
        logq: Natural log of the probability that outcome is different from argmax.
      """
      # For noisy max, we only get an upper bound via the union bound. See Lemma 4
      # in https://arxiv.org/abs/1610.05755.
      #
      # Pr[ j beats i*] = (2+gap(j,i*))/ 4 exp(gap(j,i*)
      # proof at http://mathoverflow.net/questions/66763/
  
      idx_max = np.argmax(counts)
      counts_normalized = (counts - counts[idx_max]) / lmbd
      counts_rest = np.array(
          [
              counts_normalized[i]
              for i in range(len(counts))
              if i != idx_max
          ]
      )
  
      logq = _logaddexp(
          np.log(2 - counts_rest) + math.log(0.25) + counts_rest
      )
  
      return min(logq, math.log(1 - (1 / len(counts))))
  
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 12 for calling a global function with example usage: compute_logq_laplace(counts, lmbd) and returns: min