code: def _compute_delta(orders, rdp, eps):
      """Compute delta given a list of RDP values and target epsilon.
  
      Args:
        orders: An array (or a scalar) of orders.
        rdp: A list (or a scalar) of RDP guarantees.
        eps: The target epsilon.
  
      Returns:
        Pair of (delta, optimal_order).
  
      Raises:
        ValueError: If input is malformed.
  
      """
      orders_vec = np.atleast_1d(orders)
      rdp_vec = np.atleast_1d(rdp)
  
      if eps < 0:
          raise ValueError(
              "Value of privacy loss bound epsilon must be >=0."
          )
      if len(orders_vec) != len(rdp_vec):
          raise ValueError("Input lists must have the same length.")
  
      # Basic bound (see https://arxiv.org/abs/1702.07476 Proposition 3 in v3):
      #   delta = min( np.exp((rdp_vec - eps) * (orders_vec - 1)) )
  
      # Improved bound from https://arxiv.org/abs/2004.00010 Proposition 12 (in v4):
      logdeltas = []  # work in log space to avoid overflows
      for a, r in zip(orders_vec, rdp_vec):
          if a < 1:
              raise ValueError("Renyi divergence order must be >=1.")
          if r < 0:
              raise ValueError("Renyi divergence must be >=0.")
          # For small alpha, we are better of with bound via KL divergence:
          # delta <= sqrt(1-exp(-KL)).
          # Take a min of the two bounds.
          logdelta = 0.5 * math.log1p(-math.exp(-r))
          if a > 1.01:
              # This bound is not numerically stable as alpha->1.
              # Thus we have a min value for alpha.
              # The bound is also not useful for small alpha, so doesn't matter.
              rdp_bound = (a - 1) * (
                  r - eps + math.log1p(-1 / a)
              ) - math.log(a)
              logdelta = min(logdelta, rdp_bound)
  
          logdeltas.append(logdelta)
  
      idx_opt = np.argmin(logdeltas)
      return min(math.exp(logdeltas[idx_opt]), 1.0), orders_vec[idx_opt]
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import math
  import sys
  import numpy
  from scipy import special
  import six
label_desc: Use image node_id 10 for calling a global function with example usage: _compute_delta(orders, rdp, eps) and returns: min,  orders_vec