Hello, I am currently implementing an automated machine learning algorithm with weight inheritance. I implemented my NNs as networkx graphs. Since I mutate the graphs from one generation to another, I add new layers and hence need to pass those to the cuda device again. I do this in the a for loop over the nodes in the graph in the the forward pass. In each iteration of the loop, I first pass the nodes nn.module to the cuda device then forward pass the data through it. My issue is that I get the above mentioned error message at some point. Is there anyway to avoid this issue ?`
def forward(self, inputs):
# Evaluate the graph in topological ordering
topological_order = nx.algorithms.dag.topological_sort(self)
    self.nodes[self.get_input_nodes()]['output'] = inputs

    for node in topological_order:
        # try:
        node_info = self.nodes[node]
        node_info['op'].to(device)

        preds = list(self.predecessors(node))

        if len(preds) > 0:
            cell_input = [self.nodes[pred]['output'] for pred in preds]
            if node_info['type'] == 'merge':
                node_info['output'] = node_info['op'](cell_input)
            else:
                node_info['output'] = node_info['op'](cell_input[0])

            node_info['params']['output_dim'] = node_info['output'].size()

    return [self.nodes[node]['output'] for node in self.get_output_nodes()][0]`