class_docstr: Abstract class offering interface shared between all PyTorch Neural Modules.
class_docstr_tok: ["Abstract","class","offering","interface","shared","between","all","PyTorch","Neural","Modules","."]
docstr: Context manager which temporarily freezes a module, yields control and finally unfreezes the module.
docstr_tok: ["Context","manager","which","temporarily","freezes","a","module",",","yields","control","and","finally","unfreezes","the","module","."]
code: def as_frozen(self):
      """
      Context manager which temporarily freezes a module, yields control and finally unfreezes the module.
      """
      training_mode = self.training
      grad_map = {}
      for pname, param in self.named_parameters():
          grad_map[pname] = param.requires_grad
  
      self.freeze()
      try:
          yield
      finally:
          self.unfreeze()
  
          for pname, param in self.named_parameters():
              param.requires_grad = grad_map[pname]
  
          if training_mode:
              self.train()
          else:
              self.eval()
  
file_path: NeMo/nemo/core/classes/module.py
imports: from contextlib import contextmanager
  import torch
  from torch.nn import Module
  from nemo.core.classes.common import FileIO, Serialization, Typing
label_desc: Use image node_id 6 for calling the NeuralModule obj's underlying member method code with example usage: obj.as_frozen() without return types