code: def _rename_node_in_fn(node, new_name, fn):
      """
      Rename a node and all it's connections.
  
      Parameters
      ----------
      node: ParsedTFNode
          Node to rename.
      new_name: str
          New name of the node.
      fn: SSAFunction
          Function that contains graph to operate on.
      """
      old_name = node.name
      node.name = new_name
      for i in node.inputs:
          idx = fn.graph[i].outputs.index(old_name)
          fn.graph[i].outputs[idx] = new_name
          if old_name in fn.graph[i].control_outputs:
              idx = fn.graph[i].control_outputs.index(old_name)
              fn.graph[i].control_outputs[idx] = new_name
  
      for o in node.outputs:
          idx = fn.graph[o].inputs.index(old_name)
          fn.graph[o].inputs[idx] = new_name
          if old_name in fn.graph[o].control_inputs:
              idx = fn.graph[o].control_inputs.index(old_name)
              fn.graph[o].control_inputs[idx] = new_name
  
      for i in node.control_inputs:
          if old_name in fn.graph[i].control_outputs:
              idx = fn.graph[i].control_outputs.index(old_name)
              fn.graph[i].control_outputs[idx] = new_name
  
      for o in node.control_outputs:
          if old_name in fn.graph[o].control_inputs:
              idx = fn.graph[o].control_inputs.index(old_name)
              fn.graph[o].control_inputs[idx] = new_name
  
      fn.graph[new_name] = fn.graph.pop(old_name)
  
file_path: turicreate/src/external/coremltools_wrap/coremltools/coremltools/converters/mil/frontend/tensorflow2/tf_graph_pass/rewrite_control_flow_functions.py
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  import logging
  from coremltools.converters.mil.frontend.tensorflow.parsed_tf_node import ParsedTFNode
  from coremltools.converters.mil.frontend.tensorflow.basic_graph_ops import disconnect_edge, connect_edge, delete_node, replace_node, replace_dest, connect_edge_at_index
label_desc: Use image node_id 1 for calling a global function with example usage: _rename_node_in_fn(node, new_name, fn) without return types