class_docstr: Main entry point to the Opacus API - use ``PrivacyEngine``  to enable differential
  privacy for your model training.
  
  ``PrivacyEngine`` object encapsulates current privacy state (privacy budget +
  method it's been calculated) and exposes ``make_private`` method to wrap your
  PyTorch training objects with their private counterparts.
  
  Example:
      >>> dataloader = demo_dataloader
      >>> model = MyCustomModel()
      >>> optimizer = torch.optim.SGD(model.parameters(), lr=0.05)
      >>> privacy_engine = PrivacyEngine()
      >>>
      >>> model, optimizer, dataloader = privacy_engine.make_private(
      ...    module=model,
      ...    optimizer=optimizer,
      ...    data_loader=dataloader,
      ...    noise_multiplier=1.0,
      ...    max_grad_norm=1.0,
      ... )
      >>> # continue training as normal
class_docstr_tok: ["Main","entry","point","to","the","Opacus","API","-","use","``","PrivacyEngine","``","to","enable","differential","privacy","for","your","model","training",".","``","PrivacyEngine","``","object","encapsulates","current","privacy","state","(","privacy","budget","+","method","it","'s","been","calculated",")","and","exposes","``","make_private","``","method","to","wrap","your","PyTorch","training","objects","with","their","private","counterparts",".","Example",":",">",">",">","dataloader","=","demo_dataloader",">",">",">","model","=","MyCustomModel","(",")",">",">",">","optimizer","=","torch.optim.SGD","(","model.parameters","(",")",",","lr=0.05",")",">",">",">","privacy_engine","=","PrivacyEngine","(",")",">",">",">",">",">",">","model",",","optimizer",",","dataloader","=","privacy_engine.make_private","(","...","module=model",",","...","optimizer=optimizer",",","...","data_loader=dataloader",",","...","noise_multiplier=1.0",",","...","max_grad_norm=1.0",",","...",")",">",">",">","#","continue","training","as","normal"]
docstr: Validate that task components are compatible with DP.
  Same as ``is_compatible()``, but raises error instead of returning bool.
  
  Args:
      module: module to be checked
      optimizer: optimizer to be checked
      data_loader: data_loader to be checked
  
  Raises:
      UnsupportedModuleError
          If one or more modules found to be incompatible
docstr_tok: ["Validate","that","task","components","are","compatible","with","DP",".","Same","as","``","is_compatible","(",")","``",",","but","raises","error","instead","of","returning","bool",".","Args",":","module",":","module","to","be","checked","optimizer",":","optimizer","to","be","checked","data_loader",":","data_loader","to","be","checked","Raises",":","UnsupportedModuleError","If","one","or","more","modules","found","to","be","incompatible"]
code: def validate(
      self,
      *,
      module: nn.Module,
      optimizer: Optional[optim.Optimizer],
      data_loader: Optional[DataLoader],
  ):
      """
      Validate that task components are compatible with DP.
      Same as ``is_compatible()``, but raises error instead of returning bool.
  
      Args:
          module: module to be checked
          optimizer: optimizer to be checked
          data_loader: data_loader to be checked
  
      Raises:
          UnsupportedModuleError
              If one or more modules found to be incompatible
      """
      ModuleValidator.validate(module, strict=True)
  
imports: import os
  import warnings
  from itertools import chain
  from typing import IO, Any, BinaryIO, Dict, List, Optional, Tuple, Union
  import torch
  from opacus.accountants import create_accountant
  from opacus.accountants.utils import get_noise_multiplier
  from opacus.data_loader import DPDataLoader, switch_generator
  from opacus.distributed import DifferentiallyPrivateDistributedDataParallel
  from opacus.grad_sample import AbstractGradSampleModule, GradSampleModule, get_gsm_class, wrap_model
  from opacus.optimizers import DPOptimizer, get_optimizer_class
  from opacus.schedulers import _GradClipScheduler, _NoiseScheduler
  from opacus.validators.module_validator import ModuleValidator
  from torch import nn, optim
  from torch.nn.parallel import DistributedDataParallel
  from torch.utils.data import DataLoader
label_desc: Use image node_id 6 for calling the PrivacyEngine obj's underlying member method code with example usage: obj.validate() without return types