code: def prepare(self):
      self._build_graph()
      self._prepare_travel_graph()
      self._travel_graph(self.net_outputs)
      for r in self.run_list[:]:
          for inp in r.inputs:
              if inp in self.run_list:
                  self.run_list.remove(inp)
  
          # When the number of node outputs is huge, merging will be abandoned because it takes a lot of time.
          output_num = self._get_node_output_num(r)
          if output_num > 50:
              self.run_list.remove(r)
              self.run_list.extend(r.inputs)
  
      self._merge_run_list()
  
      for name, op in self.op_dict.items():
          if op.node.op == "Placeholder":
              shape = [d.size for d in op.node.attr["shape"].shape.dim]
              if len(shape) != 4:
                  raise Exception("illegal placeholder shape")
              shape = [shape[i] for i in [0, 2, 3, 1]]
              op.node.attr["shape"].shape.Clear()
              op.node.attr["shape"].shape.CopyFrom(
                  tf.TensorShape(shape).as_proto()
              )
  
          for i in range(len(op.node.input)):
              if op.node.input[i] in self._rename_node_dict:
                  op.node.input[i] = self._rename_node_dict[
                      op.node.input[i]
                  ]
  
imports: import numpy
  import tensorflow.compat.v1
  from tensorflow.core.framework.tensor_pb2 import TensorProto
  from tensorflow.core.framework.tensor_shape_pb2 import TensorShapeProto
label_desc: Use image node_id 16 for calling the RefineGraph obj's underlying member method code with example usage: obj.prepare() without return types