def rename_node(self, src_node, tgt_node):
        """
        Rename the node with node name (src_node) to (tgt_node).
        Note that the name (tgt_node) cannot appear in the whole network,
        not only the function it lies in.
        """
        in_ssa = False
        success = None
        for func, tfssa in self.functions.items():
            if src_node in tfssa.graph:
                in_ssa = True
                if tgt_node in tfssa.graph:
                    logger.warning(
                        "(%s) already exists in function (%s).", tgt_node, func
                    )
                    break
                success = func
                tfssa.graph[tgt_node] = tfssa.graph.pop(src_node)
                # Replace other nodes' output dependency
                for inp in tfssa.graph[tgt_node].inputs:
                    for idx, out in enumerate(tfssa.graph[inp].outputs):
                        if out == src_node:
                            tfssa.graph[inp].outputs[idx] = tgt_node
                            break
                # Replace other nodes' control output dependency
                for c_inp in tfssa.graph[tgt_node].control_inputs:
                    for idx, c_out in enumerate(tfssa.graph[c_inp].control_outputs):
                        if c_out == src_node:
                            tfssa.graph[c_inp].control_outputs[idx] = tgt_node
                            break
                # Replace other nodes' input dependency
                for out in tfssa.graph[tgt_node].outputs:
                    for idx, inp in enumerate(tfssa.graph[out].inputs):
                        if inp == src_node:
                            tfssa.graph[out].inputs[idx] = tgt_node
                            break
                # Replace other nodes' control input dependency
                for c_out in tfssa.graph[tgt_node].control_outputs:
                    for idx, c_inp in enumerate(tfssa.graph[c_out].control_inputs):
                        if c_inp == src_node:
                            tfssa.graph[c_out].control_inputs[idx] = tgt_node
                            break
                break

        if not in_ssa:
            logger.warning("Couldn't find (%s) in any functions", src_node)
        if success is not None:
            logger.debug(
                "Changed (%s) to (%s) in function (%s)", src_node, tgt_node, success
            )

        Rename the node with node name (src_node) to (tgt_node).
        Note that the name (tgt_node) cannot appear in the whole network,
        not only the function it lies in.
        
coremltools/converters/mil/frontend/tensorflow/tfssa.py