class_docstr: A wrapper for transparently flattening a Module's parameters.
  
  Compared to the original implementation [1], this version:
  - removes tracing
  - supports shared parameters
  - handles state_dict/load_state_dict transparently
  - is renamed to FlattenParamsWrapper
  - refactored to use the FlatParameter class
  - extended to support flattening multiple groups of params (useful
    when different groups of params need different hyperparameters, like
    learning rate or weight decay)
  
  [1] https://github.com/SsnL/PyTorch-Reparam-Module
  
  Args:
      module (nn.Module):
          The module to wrap.
      param_list (Optional[List[List[nn.Parameter]]]):
          Only flatten parameters appearing in the given groups.
          If the param_list is an empty list, then no parameters will get flattened.
          Note, if a single param is in one of the list, it still get flattened and the
          original param is removed and replaced with the flatten one.
          Default: None, flatten all parameters (if any)
      flat_param_names (Optional[List[str]]):
          originally, give each flat_param a unique name. Note a "flat_param_"
          prefix will be added to those names.
class_docstr_tok: ["A","wrapper","for","transparently","flattening","a","Module","'s","parameters",".","Compared","to","the","original","implementation","[","1","]",",","this","version",":","-","removes","tracing","-","supports","shared","parameters","-","handles","state_dict\/load_state_dict","transparently","-","is","renamed","to","FlattenParamsWrapper","-","refactored","to","use","the","FlatParameter","class","-","extended","to","support","flattening","multiple","groups","of","params","(","useful","when","different","groups","of","params","need","different","hyperparameters",",","like","learning","rate","or","weight","decay",")","[","1","]","https",":","\/\/github.com\/SsnL\/PyTorch-Reparam-Module","Args",":","module","(","nn.Module",")",":","The","module","to","wrap",".","param_list","(","Optional","[","List","[","List","[","nn.Parameter","]","]","]",")",":","Only","flatten","parameters","appearing","in","the","given","groups",".","If","the","param_list","is","an","empty","list",",","then","no","parameters","will","get","flattened",".","Note",",","if","a","single","param","is","in","one","of","the","list",",","it","still","get","flattened","and","the","original","param","is","removed","and","replaced","with","the","flatten","one",".","Default",":","None",",","flatten","all","parameters","(","if","any",")","flat_param_names","(","Optional","[","List","[","str","]","]",")",":","originally",",","give","each","flat_param","a","unique","name",".","Note","a","``","flat_param_","''","prefix","will","be","added","to","those","names","."]
docstr: Undo flattening and create separate parameters from the already flattened
  self.flat_param or a user supplied external data.
docstr_tok: ["Undo","flattening","and","create","separate","parameters","from","the","already","flattened","self.flat_param","or","a","user","supplied","external","data","."]
code: def _unflatten_params(
      self, external_data: Optional[List[Optional[Tensor]]] = None
  ) -> None:
      """Undo flattening and create separate parameters from the already flattened
      self.flat_param or a user supplied external data.
      """
      assert self.is_flattened or external_data is not None
      self.is_flattened = False
  
      ps = self.get_param_views(external_data)
      for (_, m, n), p in zip(self._param_infos, ps):
          if hasattr(m, n):
              delattr(m, n)
          m.register_parameter(n, nn.Parameter(p))
      for _, _, m, n, shared_m, shared_n in self._shared_param_infos:
          if hasattr(m, n):
              delattr(m, n)
          m.register_parameter(n, getattr(shared_m, shared_n))
  
      # Delete the param views into the flat params since we will delete the
      # flat params next
      if hasattr(self._fpw_module, "_unflattened_param_views"):
          delattr(self._fpw_module, "_unflattened_param_views")
  
      for n in self.flat_param_names:
          # This ensures the flat params are removed from the module.
          delattr(self, n)
      self.flat_params = []
  
imports: from contextlib import contextmanager
  from itertools import chain
  import typing
  from typing import TYPE_CHECKING, Any, Dict, Generator, Iterator, List, Mapping, NamedTuple, Optional, Sequence, Set, Tuple, Union, cast
  import torch
  from torch import Tensor
  import torch.nn
  from fairscale.internal.state_dict import replace_by_prefix_
label_desc: Use image node_id 8 for calling the FlattenParamsWrapper obj's underlying member method code with example usage: obj._unflatten_params(external_data) without return types