Copy all nodes from a given graph into ``self``. Args: g (Graph): The source graph from which to copy Nodes. val_map (Dict[Node, Node]): a dictionary that will be populated with a mapping from nodes in ``g`` to nodes in ``self``. Note that
(self, g : 'Graph', val_map : Dict[Node, Node], return_output_node=False)
| 819 | |
| 820 | @compatibility(is_backward_compatible=True) |
| 821 | def graph_copy(self, g : 'Graph', val_map : Dict[Node, Node], return_output_node=False) -> 'Optional[Argument]': |
| 822 | """ |
| 823 | Copy all nodes from a given graph into ``self``. |
| 824 | |
| 825 | Args: |
| 826 | |
| 827 | g (Graph): The source graph from which to copy Nodes. |
| 828 | |
| 829 | val_map (Dict[Node, Node]): a dictionary that will be populated with a mapping |
| 830 | from nodes in ``g`` to nodes in ``self``. Note that ``val_map`` can be passed |
| 831 | in with values in it already to override copying of certain values. |
| 832 | |
| 833 | Returns: |
| 834 | |
| 835 | The value in ``self`` that is now equivalent to the output value in ``g``, |
| 836 | if ``g`` had an ``output`` node. ``None`` otherwise. |
| 837 | """ |
| 838 | for node in g.nodes: |
| 839 | if node in val_map: |
| 840 | continue |
| 841 | if node.op == 'output': |
| 842 | rv = map_arg(node.args[0], lambda n: val_map[n]) |
| 843 | return rv if not return_output_node else (rv, node) |
| 844 | val_map[node] = self.node_copy(node, lambda n : val_map[n]) |
| 845 | return None |
| 846 | |
| 847 | def __deepcopy__(self, memo=None) -> 'Graph': |
| 848 | """ |