code: def _compute_rdp(
      votes,
      baseline,
      threshold,
      sigma1,
      sigma2,
      delta,
      orders,
      data_ind,
  ):
      """Computes the (data-dependent) RDP curve for Confident GNMax."""
      rdp_cum = np.zeros(len(orders))
      rdp_sqrd_cum = np.zeros(len(orders))
      answered = 0
  
      for i, v in enumerate(votes):
          if threshold is None:
              logq_step1 = (
                  0  # No thresholding, always proceed to step 2.
              )
              rdp_step1 = np.zeros(len(orders))
          else:
              logq_step1 = pate.compute_logpr_answered(
                  threshold, sigma1, v - baseline[i,]
              )
              if data_ind:
                  rdp_step1 = (
                      pate.compute_rdp_data_independent_threshold(
                          sigma1, orders
                      )
                  )
              else:
                  rdp_step1 = pate.compute_rdp_threshold(
                      logq_step1, sigma1, orders
                  )
  
          if data_ind:
              rdp_step2 = pate.rdp_data_independent_gaussian(
                  sigma2, orders
              )
          else:
              logq_step2 = pate.compute_logq_gaussian(v, sigma2)
              rdp_step2 = pate.rdp_gaussian(logq_step2, sigma2, orders)
  
          q_step1 = np.exp(logq_step1)
          rdp = rdp_step1 + rdp_step2 * q_step1
          # The expression below evaluates
          #     E[(cost_of_step_1 + Bernoulli(pr_of_step_2) * cost_of_step_2)^2]
          rdp_sqrd = (
              rdp_step1**2
              + 2 * rdp_step1 * q_step1 * rdp_step2
              + q_step1 * rdp_step2**2
          )
          rdp_sqrd_cum += rdp_sqrd
  
          rdp_cum += rdp
          answered += q_step1
          if ((i + 1) % 1000 == 0) or (i == votes.shape[0] - 1):
              rdp_var = (
                  rdp_sqrd_cum / i - (rdp_cum / i) ** 2
              )  # Ignore Bessel's correction.
              eps_total, order_opt = pate.compute_eps_from_delta(
                  orders, rdp_cum, delta
              )
              order_opt_idx = np.searchsorted(orders, order_opt)
              eps_std = (
                  (i + 1) * rdp_var[order_opt_idx]
              ) ** 0.5  # Std of the sum.
              print(
                  "queries = {}, E[answered] = {:.2f}, E[eps] = {:.3f} (std = {:.5f}) "
                  "at order = {:.2f} (contribution from delta = {:.3f})".format(
                      i + 1,
                      answered,
                      eps_total,
                      eps_std,
                      order_opt,
                      -math.log(delta) / (order_opt - 1),
                  )
              )
              sys.stdout.flush()
  
          _, order_opt = pate.compute_eps_from_delta(
              orders, rdp_cum, delta
          )
  
      return order_opt
  
file_path: privacy/research/pate_2018/ICLR2018/smooth_sensitivity_table.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import math
  import os
  import sys
  from absl import app
  from absl import flags
  import numpy
  import core
  import smooth_sensitivity
label_desc: Use image node_id 2 for calling a global function with example usage: _compute_rdp(votes, baseline, threshold, sigma1, sigma2, delta, orders, data_ind) and returns: order_opt