class_docstr: This class defines an nn.Module whose parameters are renamed. This is useful when you want to
  reimplement a layer but make sure its state_dict and list of parameters are exactly the same
  as another reference layer so that you can have a drop-in replacement that does not depend on
  how your layer is actually implemented. In Opacus, this is used for DPLSTM, where our
  implementation leverages submodules and requires alignment to the state_dict of nn.LSTM.
  
  Example:
  
      >>> class DPModel(RenameParamsMixin, nn.Module):
      ...    def __init__(self, hidden_size):
      ...        super().__init__()
      ...        self.w = nn.Parameter(torch.zeros(hidden_size, requires_grad=True))
      ...        self.set_rename_map({"w": "weights"})
      ...
      >>> model = DPModel(5)
      >>> model.state_dict()
      {'weights': tensor([0., 0., 0., 0., 0.])}
docstr: Identical to ``torch.nn.Module.load_state_dict()`` but handles the renamed keys.
docstr_tok: ["Identical","to","``","torch.nn.Module.load_state_dict","(",")","``","but","handles","the","renamed","keys","."]
code: def load_state_dict(
      self,
      state_dict: Dict[str, Tensor],
      strict: bool = True,
  ):
      """
      Identical to ``torch.nn.Module.load_state_dict()`` but handles the renamed keys.
      """
  
      # nn.Module recomputes its state_dict(), without calling the same logic as in self.state_dict()
      # This means that it will find both the old and the renamed parameters. Both point to the
      # same parameter object, so either of them will set it correctly. It will however complain
      # that some keys are missing (the "old" keys). We can safely ignore those and process them
      # accordingly
  
      missing_keys, unexpected_keys = super().load_state_dict(
          state_dict, strict=False
      )
      missing_keys = [
          k for k in missing_keys if k not in self.old_to_new
      ]
      if strict:
          error_msgs = []
          if len(unexpected_keys) > 0:
              error_msgs.insert(
                  0,
                  "Unexpected key(s) in state_dict: {}. ".format(
                      ", ".join(
                          '"{}"'.format(k) for k in unexpected_keys
                      )
                  ),
              )
          if len(missing_keys) > 0:
              error_msgs.insert(
                  0,
                  "Missing key(s) in state_dict: {}. ".format(
                      ", ".join('"{}"'.format(k) for k in missing_keys)
                  ),
              )
  
          if len(error_msgs) > 0:
              raise RuntimeError(
                  "Error(s) in loading state_dict for {}:\n\t{}".format(
                      self.__class__.__name__, "\n\t".join(error_msgs)
                  )
              )
      return _IncompatibleKeys(missing_keys, unexpected_keys)
  
file_path: opacus/opacus/layers/param_rename.py
imports: from typing import Dict, Union
  import torch.nn
  from torch import Tensor
  from torch.nn.modules.module import _IncompatibleKeys
label_desc: Use image node_id 4 for calling the RenameParamsMixin obj's underlying member method code with example usage: obj.load_state_dict(state_dict, strict) and returns: _IncompatibleKeys