code: def compute_dp_sgd_privacy(
      n, batch_size, noise_multiplier, epochs, delta
  ):
      """Compute epsilon based on the given hyperparameters.
  
      This function is deprecated. It does not account for doubling of sensitivity
      with microbatching, and assumes Poisson subsampling, which is rarely used in
      practice. (See "How to DP-fy ML: A Practical Guide to Machine Learning with
      Differential Privacy", https://arxiv.org/abs/2303.00654, Sec 5.6.) Most users
      should call `compute_dp_sgd_privacy_statement`, which provides appropriate
      context for the guarantee (see the reporting recommendations in "How to DP-fy
      ML", Sec 5.3). If you need a numeric epsilon value under specific assumptions,
      it is recommended to use the `dp_accounting` libraries directly to compute
      epsilon, with the precise and correct assumptions of your application.
  
      Args:
        n: Number of examples in the training data.
        batch_size: Batch size used in training.
        noise_multiplier: Noise multiplier used in training.
        epochs: Number of epochs in training.
        delta: Value of delta for which to compute epsilon.
  
      Returns:
        A 2-tuple containing the value of epsilon and the optimal RDP order.
      """
      logging.warning(
          """\
  `compute_dp_sgd_privacy` is deprecated. It does not account for doubling of \
  sensitivity with microbatching, and assumes Poisson subsampling, which is \
  rarely used in practice. Please use `compute_dp_sgd_privacy_statement`, which \
  provides appropriate context for the guarantee. To compute epsilon under \
  different assumptions than those in `compute_dp_sgd_privacy_statement`, call \
  the `dp_accounting` libraries directly."""
      )
  
      q = batch_size / n  # q - the sampling ratio.
      if q > 1:
          raise app.UsageError("n must be larger than the batch size.")
      orders = (
          [1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 3.0, 3.5, 4.0, 4.5]
          + list(range(5, 64))
          + [128, 256, 512]
      )
      steps = int(math.ceil(epochs * n / batch_size))
      accountant = dp_accounting.rdp.RdpAccountant(orders)
  
      event = dp_accounting.SelfComposedDpEvent(
          dp_accounting.PoissonSampledDpEvent(
              sampling_probability=q,
              event=dp_accounting.GaussianDpEvent(noise_multiplier),
          ),
          steps,
      )
  
      accountant.compose(event)
      return accountant.get_epsilon_and_optimal_order(delta)
  
file_path: privacy/tensorflow_privacy/privacy/analysis/compute_dp_sgd_privacy_lib.py
imports: import enum
  import functools
  import math
  import textwrap
  from typing import Optional
  from absl import app
  from absl import logging
  import dp_accounting
  from scipy import optimize
label_desc: Use image node_id 5 for calling a global function with example usage: compute_dp_sgd_privacy(n, batch_size, noise_multiplier, epochs, delta) and returns: accountant