code: def make_functional(
      mod: nn.Module, disable_autograd_tracking: bool = False
  ):
      """
      Helper method to mimic deprecated `functorch.make_functional()` behaviour. See
      https://pytorch.org/docs/master/func.migrating.html
  
      Args:
          mod: module to be converted to functional
          disable_autograd_tracking:
  
      Returns:
          Tuple with cloned model and new params
      """
      params_dict = dict(mod.named_parameters())
      params_names = params_dict.keys()
      params_values = tuple(params_dict.values())
  
      stateless_mod = copy.deepcopy(mod)
      stateless_mod.to("meta")
  
      if hasattr(stateless_mod, "allow_grad_accumulation"):
          stateless_mod.allow_grad_accumulation()
  
      def fmodel(new_params_values, *args, **kwargs):
          new_params_dict = {
              name: value
              for name, value in zip(params_names, new_params_values)
          }
          return torch.func.functional_call(
              stateless_mod, new_params_dict, args, kwargs
          )
  
      if disable_autograd_tracking:
          params_values = torch.utils._pytree.tree_map(
              torch.Tensor.detach, params_values
          )
      return fmodel, params_values
  
file_path: opacus/opacus/grad_sample/functorch.py
imports: import copy
  import torch
  import torch.nn
  from opacus.layers.dp_rnn import RNNLinear
  from torch.func import grad, vmap
label_desc: Use image node_id 1 for calling a global function with example usage: make_functional(mod, disable_autograd_tracking) and returns: fmodel,  params_values, torch