code: def make_functional(
      module: _torch.nn.Module, encapsulator: _EncapsulatorType = None
  ) -> _MonkeyPatchBase:
      r"""Returns a stateless version of an ``nn.Module`` instance."""
      params_box = [None]
      _, fmodule, MonkeyPatched = _make_functional(
          module, params_box, 0
      )
      top_name = "Functional" + MonkeyPatched._wrapped_name
      MonkeyPatched.__name__ = MonkeyPatched.__qualname__ = top_name
  
      MonkeyPatched.boxed_forward = MonkeyPatched.forward
  
      param_mapping = _utils._get_param_mapping(module, [], [])
      setattr(fmodule, "_param_mapping", param_mapping)
  
      def _refill_params_box(self, params):
          if params is not None:
              self.fast_params = (
                  params  # update view on latest fast params
              )
          elif self.fast_params is None:
              raise ValueError(
                  "params keyword must be provided if patched module not "
                  "tracking its own fast parameters"
              )
  
          # Copy fast parameters into params_box for use in boxed_forward
          params_box[0] = self._expand_params(self.fast_params)
  
      def _patched_forward(self, *args, params=None, **kwargs):
          self._refill_params_box(params)
  
          output = self.boxed_forward(*args, **kwargs)
  
          # Clean up
          params_box[0] = None
  
          return output
  
      def _update_params(self, params):
          self.fast_params = params
          params = self._expand_params(params)
          _update_patched_params(self, [params], 0)
  
      setattr(MonkeyPatched, "forward", _patched_forward)
      setattr(MonkeyPatched, "parameters", _patched_parameters)
      setattr(MonkeyPatched, "update_params", _update_params)
      setattr(MonkeyPatched, "_refill_params_box", _refill_params_box)
  
      if encapsulator is not None:
          encapsulator(fmodule, module)
  
      return fmodule
  
imports: import abc
  from collections import OrderedDict
  from contextlib import contextmanager
  import typing
  import weakref
  import warnings
  import torch
  from .None import utils
label_desc: Use image node_id 6 for calling a global function with example usage: make_functional(module, encapsulator) and returns: fmodule, output