code: def _compute_dp_sgd_example_privacy(
      num_epochs: float,
      noise_multiplier: float,
      example_delta: float,
      used_microbatching: bool = True,
      poisson_subsampling_probability: Optional[float] = None,
      accountant_type: AccountantType = AccountantType.RDP,
  ) -> float:
      """Computes add-or-remove-one-example DP epsilon.
  
      This privacy guarantee uses add-or-remove-one-example adjacency, and protects
      release of all model checkpoints in addition to the final model.
  
      Args:
        num_epochs: The number of passes over the data.
        noise_multiplier: The ratio of the noise stddev to the l2 sensitivity.
        example_delta: The target delta.
        used_microbatching: If true, increases sensitivity by a factor of two.
        poisson_subsampling_probability: If not None, gives the probability that
          each record is chosen in a batch. If None, assumes no subsampling.
        accountant_type: The privacy accountant for computing epsilon.
  
      Returns:
        The epsilon value.
      """
      if num_epochs <= 0:
          raise ValueError(
              f"num_epochs must be positive. Found {num_epochs}."
          )
      if noise_multiplier < 0:
          raise ValueError(
              f"noise_multiplier must be non-negative. Found {noise_multiplier}."
          )
      if not 0 <= example_delta <= 1:
          raise ValueError(
              f"delta must be between 0 and 1. Found {example_delta}."
          )
  
      if used_microbatching:
          # TODO(b/271462792)
          noise_multiplier /= 2
  
      event_ = dp_accounting.GaussianDpEvent(noise_multiplier)
      if poisson_subsampling_probability is not None:
          event_ = dp_accounting.PoissonSampledDpEvent(
              sampling_probability=poisson_subsampling_probability,
              event=event_,
          )
          count = int(
              math.ceil(num_epochs / poisson_subsampling_probability)
          )
      else:
          count = int(math.ceil(num_epochs))
      event_ = dp_accounting.SelfComposedDpEvent(
          count=count, event=event_
      )
  
      return (
          accountant_type.get_accountant()
          .compose(event_)
          .get_epsilon(example_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 3 for calling a global function with example usage: _compute_dp_sgd_example_privacy(num_epochs, noise_multiplier, example_delta, used_microbatching, poisson_subsampling_probability, accountant_type) and returns: accountant_type