class_docstr: :class:`~opacus.optimizers.optimizer.DPOptimizer` that implements
  adaptive clipping strategy
  https://arxiv.org/pdf/1905.03871.pdf
class_docstr_tok: [":","class",":","`","~opacus.optimizers.optimizer.DPOptimizer","`","that","implements","adaptive","clipping","strategy","https",":","\/\/arxiv.org\/pdf\/1905.03871.pdf"]
code: def __init__(
      self,
      optimizer: Optimizer,
      *,
      noise_multiplier: float,
      target_unclipped_quantile: float,
      clipbound_learning_rate: float,
      max_clipbound: float,
      min_clipbound: float,
      unclipped_num_std: float,
      max_grad_norm: float,
      expected_batch_size: Optional[int],
      loss_reduction: str = "mean",
      generator=None,
      secure_mode: bool = False,
  ):
      super().__init__(
          optimizer,
          noise_multiplier=noise_multiplier,
          max_grad_norm=max_grad_norm,
          expected_batch_size=expected_batch_size,
          loss_reduction=loss_reduction,
          generator=generator,
          secure_mode=secure_mode,
      )
      assert (
          max_clipbound > min_clipbound
      ), "max_clipbound must be larger than min_clipbound."
      self.target_unclipped_quantile = target_unclipped_quantile
      self.clipbound_learning_rate = clipbound_learning_rate
      self.max_clipbound = max_clipbound
      self.min_clipbound = min_clipbound
      self.unclipped_num_std = unclipped_num_std
      # Theorem 1. in  https://arxiv.org/pdf/1905.03871.pdf
      self.noise_multiplier = (
          self.noise_multiplier ** (-2)
          - (2 * unclipped_num_std) ** (-2)
      ) ** (-1 / 2)
      self.sample_size = 0
      self.unclipped_num = 0
  
file_path: opacus/opacus/optimizers/adaclipoptimizer.py
imports: from __future__ import annotations
  import logging
  from typing import Callable, Optional
  import torch
  from opt_einsum import contract
  from torch.optim import Optimizer
  from .optimizer import DPOptimizer, _check_processed_flag, _generate_noise, _mark_as_processed
label_desc: Use image node_id 1 to create a new AdaClipDPOptimizer object from inherited base classes: DPOptimizer with example: obj = AdaClipDPOptimizer(optimizer)