So right now I am trying to rebuild a module as a submodule, I think it’s a progression towards my goal of being able to replace a backbone and handle intermediary skip connections.
I have some code for creating a new module that mimics another module (but use it as a submodule):
Here is the code;
def rebuild_module_as_submodule(module: fx.GraphModule):
    module = copy.deepcopy(module)

    new_module = nn.Module()
    new_module.add_module('mod', module)

    graph = fx.Graph()
    raw1 = graph.placeholder('x')

    tracer = torch.fx.Tracer()
    tracer.root = new_module
    tracer.graph = graph

    x = fx.Proxy(raw1)

    nodes = list(module.graph.nodes)
    node2proxy = {raw1: x, nodes[0]: x}

    def nodeargs2proxy(args):
        if isinstance(args, (list, tuple)):
            return tuple(nodeargs2proxy(arg) for arg in args)
        elif isinstance(args, dict):
            return {nodeargs2proxy(key): nodeargs2proxy(val) for key, val in args.items()}
        elif isinstance(args, fx.Node):
            return node2proxy[args]
        else:
            return args

    submodules = dict(new_module.named_modules())
    
        for node in nodes[1:-1]:
        if node.op == 'call_module':
            args = nodeargs2proxy(node.args)
            kwargs = nodeargs2proxy(node.kwargs)
            node2proxy[node] = submodules[f'mod.{node.target}'](*args, **kwargs)
        elif node.op == 'call_function':
            args = nodeargs2proxy(node.args)
            kwargs = nodeargs2proxy(node.kwargs)
            node2proxy[node] = node.target(*args, **kwargs)
        elif node.op == 'call_method':
            pass
            self_obj, *args = nodeargs2proxy(node.args)
            kwargs = nodeargs2proxy(node.kwargs)
            node2proxy[node] = getattr(self_obj, node.target)(*args, **kwargs)
        else:
            raise NotImplementedError(f'Node op: op={node.op}, name={node.name}, tgt={node.target}, args={node.args}, kwargs={node.kwargs}')

    last_proxy : fx.Proxy = node2proxy[node]
    graph.output(last_proxy.node)

    return new_module, graph

def test_2():
    submodule = nn.Linear(10, 1)
    module = fx.symbolic_trace(nn.Sequential(submodule))
    new_module, graph = rebuild_module_as_submodule(module)
    print(new_module)
    print(graph)
    gm = fx.GraphModule(new_module, graph)
    print(gm)

test_2()

I am still getting the same error as before, even though I created an instance of a Tracer and assignated the module and graph I am working with.
Here is the result of the above code:
{'': Module(
  (mod): GraphModule(
    (0): Linear(in_features=10, out_features=1, bias=True)
  )
), 'mod': GraphModule(
  (0): Linear(in_features=10, out_features=1, bias=True)
), 'mod.0': Linear(in_features=10, out_features=1, bias=True)}
Module(
  (mod): GraphModule(
    (0): Linear(in_features=10, out_features=1, bias=True)
  )
)
graph(x):
    %linear_1 : [#users=1] = call_function[target=torch.nn.functional.linear](args = (%x, Parameter containing:
tensor([[-0.3050,  0.0150, -0.2705, -0.0750, -0.0539, -0.0999,  0.0665, -0.0039,
          0.3120, -0.2078]], requires_grad=True)), kwargs = {bias: Parameter containing:
tensor([0.1116], requires_grad=True)})
    return linear_1
Traceback (most recent call last):
  File "test.py", line 91, in <module>
    test_2()
  File "test.py", line 88, in test_2
    gm = fx.GraphModule(new_module, graph)
  File "/home/SERILOCAL/n.perto/.anaconda3/envs/automl/lib/python3.7/site-packages/torch/fx/graph_module.py", line 194, in __init__
    self.graph = graph
  File "/home/SERILOCAL/n.perto/.anaconda3/envs/automl/lib/python3.7/site-packages/torch/nn/modules/module.py", line 995, in __setattr__
    object.__setattr__(self, name, value)
  File "/home/SERILOCAL/n.perto/.anaconda3/envs/automl/lib/python3.7/site-packages/torch/fx/graph_module.py", line 217, in graph
    self.recompile()
  File "/home/SERILOCAL/n.perto/.anaconda3/envs/automl/lib/python3.7/site-packages/torch/fx/graph_module.py", line 297, in recompile
    cls.forward = _forward_from_src(self._code)
  File "/home/SERILOCAL/n.perto/.anaconda3/envs/automl/lib/python3.7/site-packages/torch/fx/graph_module.py", line 41, in _forward_from_src
    exec_with_source(src, gbls)
  File "/home/SERILOCAL/n.perto/.anaconda3/envs/automl/lib/python3.7/site-packages/torch/fx/graph_module.py", line 26, in exec_with_source
    exec(compile(src, key, 'exec'), globals)
  File "<eval_with_key_2>", line 3
    linear_1 = torch.nn.functional.linear(x, Parameter containing:
                                                                ^
SyntaxError: invalid syntax

It is still this problem of parameters that are missing from the module, and I don’t know how to handle it in my case.
Do you have any idea how to fix this?