def METHOD_NAME(self, mod, disable_autograd_tracking=False):
    # relies on the code snippet from https://tinyurl.com/hrv99cuk
    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')
    def fmodel(new_params_values, *args, **kwargs):
        new_params_dict = dict(zip(params_names, new_params_values))
        return functional_call(stateless_mod, new_params_dict, args, kwargs)
    if disable_autograd_tracking:
        params_values = tree_map(torch.Tensor.detach, params_values)
    return fmodel, params_values