class_docstr: PyTorch module, but with uncertainties.
  
  This base class provides useful tools to handle search spaces built on top of PyTorch modules,
  including methods like :meth:`simplify`, :meth:`freeze`.
  
  :class:`MutableModule` can have dangling mutables registered on it via :meth:`add_mutable`.
class_docstr_tok: ["PyTorch","module",",","but","with","uncertainties",".","This","base","class","provides","useful","tools","to","handle","search","spaces","built","on","top","of","PyTorch","modules",",","including","methods","like",":","meth",":","`","simplify","`",",",":","meth",":","`","freeze","`",".",":","class",":","`","MutableModule","`","can","have","dangling","mutables","registered","on","it","via",":","meth",":","`","add_mutable","`","."]
docstr: Return a frozen version of current mutable module.
  Some sub-modules can be possibly deep-copied.
  
  If mutables are added to the module via :meth:`add_mutable`, this method must be implemented.
  Otherwise, it will simply look at the children modules and freeze them recursively.
  
  :meth:`freeze` of subclass is encouraged to keep the original weights at best effort,
  but no guarantee is made, unless otherwise specified.
code: def freeze(self, sample: Dict[str, Any]) -> nn.Module:
      """Return a frozen version of current mutable module.
      Some sub-modules can be possibly deep-copied.
  
      If mutables are added to the module via :meth:`add_mutable`, this method must be implemented.
      Otherwise, it will simply look at the children modules and freeze them recursively.
  
      :meth:`freeze` of subclass is encouraged to keep the original weights at best effort,
      but no guarantee is made, unless otherwise specified.
      """
      if self.mutables:
          raise NotImplementedError(
              "freeze() must be implemented when mutables have been registered to the module. "
              "A simple way to implement this is to recreate the current module after set the frozen context:\n\n"
              "    with nni.nas.space.model_context(sample):\n"
              "        return self.__class__(*args, **kwargs)\n\n"
              "Here, `args` and `kwargs` are the arguments to the constructor of the module."
          )
  
      return recursive_freeze(self, sample, include_root=False)[0]
  
imports: import copy
  import itertools
  import inspect
  import logging
  from typing import Any, Callable, Type, Iterable, Dict, Tuple, List, Optional, TypeVar
  import torch
  from torch import nn
  from nni.mutable import Mutable, LabeledMutable, Sample, SampleValidationError, ensure_frozen, frozen_context, label_scope, frozen
  from nni.nas.space import BaseModelSpace, current_model, model_context
  from nni.common.serializer import SerializableObject, _formulate_arguments, _copy_class_wrapper_attributes
label_desc: Use image node_id 10 for calling the MutableModule obj's underlying member method code with example usage: obj.freeze(sample) and returns: recursive_freeze