docstr: Call this method to disable sparsity and restore all weights.
  This will only work if init(...) was called with allow_recompute=True.
docstr_tok: ["Call","this","method","to","disable","sparsity","and","restore","all","weights",".","This","will","only","work","if","init","(","...",")","was","called","with","allow_recompute=True","."]
code: def restore_pruned_weights(cls):
      """Call this method to disable sparsity and restore all weights.
      This will only work if init(...) was called with allow_recompute=True.
      """
      with torch.no_grad():
          for (
              module_name,
              module,
              p_name,
              p,
              mask,
              pruned,
          ) in cls.__sparse_parameters:
              if mask.sum() < mask.numel():
                  assert (
                      pruned is not None
                  ), "Unable to restore dense parameter because allow_recompute_mask == False"
                  p.add_(pruned.cuda())
                  mask.fill_(1)
                  pruned.zero_()
                  if cls.__verbosity >= 2:
                      print(
                          "[ASP] Disabled sparsity for %s::%s (dense weights restored)"
                          % (module_name, p_name)
                      )
  
file_path: apex/apex/contrib/sparsity/asp.py
imports: import types
  import torch
  from .sparse_masklib import create_mask
  from .permutation_lib import Permutation
  import json
  import os
  import string
  import time
label_desc: Use image node_id 5 for calling the ASP obj's underlying member method code with example usage: obj.restore_pruned_weights(cls) without return types