code: def replace_apply_state(meta_graph, state_ops, feed_map):
    
    for node in meta_graph.graph_def.node:
      keys_to_purge = []
      tensor_name = node.name + ":0"
      # Verify that the node is a state op and that its due to be rewired
      # in the feedmap.
      if node.op in state_ops and tensor_name in feed_map:
        node.op = "Placeholder"
        for key in node.attr:
          # Only shape and dtype are required for Placeholder. Remove other
          # attributes.
          if key != "shape":
            keys_to_purge.append(key)
        for key in keys_to_purge:
          del node.attr[key]
        node.attr["dtype"].type = types_pb2.DT_RESOURCE
docs: Replaces state ops with non state Placeholder ops for the apply graph.