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"]
code: def load_checkpoint(
      self,
      *,
      path: Union[str, os.PathLike, BinaryIO, IO[bytes]],
      module: GradSampleModule,
      optimizer: Optional[DPOptimizer] = None,
      noise_scheduler: Optional[_NoiseScheduler] = None,
      grad_clip_scheduler: Optional[_GradClipScheduler] = None,
      module_load_dict_kwargs: Optional[Dict[str, Any]] = None,
      torch_load_kwargs: Optional[Dict[str, Any]] = None,
  ) -> Dict:
      checkpoint = torch.load(path, **(torch_load_kwargs or {}))
      module.load_state_dict(
          checkpoint["module_state_dict"],
          **(module_load_dict_kwargs or {}),
      )
      self.accountant.load_state_dict(
          checkpoint["privacy_accountant_state_dict"]
      )
  
      optimizer_state_dict = checkpoint.pop("optimizer_state_dict", {})
      if optimizer is not None and len(optimizer_state_dict) > 0:
          optimizer.load_state_dict(optimizer_state_dict)
      elif (optimizer is not None) ^ (len(optimizer_state_dict) > 0):
          # warn if only one of them is available
          warnings.warn(
              f"optimizer_state_dict has {len(optimizer_state_dict)} items"
              f" but optimizer is {'' if optimizer else 'not'} provided."
          )
  
      noise_scheduler_state_dict = checkpoint.pop(
          "noise_scheduler_state_dict", {}
      )
      if (
          noise_scheduler is not None
          and len(noise_scheduler_state_dict) > 0
      ):
          noise_scheduler.load_state_dict(noise_scheduler_state_dict)
  
      grad_clip_scheduler_state_dict = checkpoint.pop(
          "grad_clip_scheduler_state_dict", {}
      )
      if (
          grad_clip_scheduler is not None
          and len(grad_clip_scheduler_state_dict) > 0
      ):
          grad_clip_scheduler.load_state_dict(
              grad_clip_scheduler_state_dict
          )
  
      return checkpoint
  
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 12 for calling the PrivacyEngine obj's underlying member method code with example usage: obj.load_checkpoint() and returns: checkpoint