docstr: A simple conv-net for classifying MNIST with differential privacy training
  Args:
      lr: Learning rate
      enable_dp: Enables training with privacy guarantees using Opacus (if True), vanilla SGD otherwise
      delta: Target delta for which (eps, delta)-DP is computed
      noise_multiplier: Noise multiplier
      max_grad_norm: Clip per-sample gradients to this norm
docstr_tok: ["A","simple","conv-net","for","classifying","MNIST","with","differential","privacy","training","Args",":","lr",":","Learning","rate","enable_dp",":","Enables","training","with","privacy","guarantees","using","Opacus","(","if","True",")",",","vanilla","SGD","otherwise","delta",":","Target","delta","for","which","(","eps",",","delta",")","-DP","is","computed","noise_multiplier",":","Noise","multiplier","max_grad_norm",":","Clip","per-sample","gradients","to","this","norm"]
code: def __init__(
      self,
      lr: float = 0.1,
      enable_dp: bool = True,
      delta: float = 1e-5,
      noise_multiplier: float = 1.0,
      max_grad_norm: float = 1.0,
  ):
      """A simple conv-net for classifying MNIST with differential privacy training
      Args:
          lr: Learning rate
          enable_dp: Enables training with privacy guarantees using Opacus (if True), vanilla SGD otherwise
          delta: Target delta for which (eps, delta)-DP is computed
          noise_multiplier: Noise multiplier
          max_grad_norm: Clip per-sample gradients to this norm
      """
      super().__init__()
  
      # Hyper-parameters
      self.lr = lr
  
      # Parameters
      self.conv1 = nn.Conv2d(1, 16, 8, 2, padding=3)
      self.conv2 = nn.Conv2d(16, 32, 4, 2)
      self.fc1 = nn.Linear(32 * 4 * 4, 32)
      self.fc2 = nn.Linear(32, 10)
  
      # Metrics
      self.test_accuracy = torchmetrics.Accuracy()
  
      # Differential privacy
      self.enable_dp = enable_dp
      self.delta = delta
      self.noise_multiplier = noise_multiplier
      self.max_grad_norm = max_grad_norm
      if self.enable_dp:
          self.privacy_engine = PrivacyEngine()
  
imports: import os
  import warnings
  import pytorch_lightning
  import torch.nn
  import torch.nn.functional
  import torch.optim
  import torchmetrics
  from opacus import PrivacyEngine
  from opacus.data_loader import DPDataLoader
  from opacus.lightning import DPLightningDataModule
  from pl_bolts.datamodules import MNISTDataModule
  from pytorch_lightning.utilities.cli import LightningCLI
label_desc: Use image node_id 1 to create a new LitSampleConvNetClassifier object from inherited base classes: pl with example: obj = LitSampleConvNetClassifier(lr, enable_dp, delta, noise_multiplier, max_grad_norm)