def const_determined_nodes(gd, assume_variable_nodes=None):
    """
    Given a graph, extract all nodes that only depends on const nodes.

    # TODO: extract nodes that depends on the "const part" of placeholders.
    """
    if assume_variable_nodes is None:
        assume_variable_nodes = []
    vis = {}

    def visit(node):
        # make sure node is a ParsedNode
        if isinstance(node, str):
            node = gd[node]
        if node.name in vis:
            return

        if "Const" in node.op:
            vis[node.name] = True
        elif "Variable" in node.op:
            vis[node.name] = False
        elif "Placeholder" in node.op:
            vis[node.name] = False
        # TF1 uses TensorArray* while TF2 uses TensorList* ops
        elif "TensorArray" in node.op or "TensorList" in node.op:
            vis[node.name] = False
        elif "function" in node.op:
            vis[node.name] = False
        elif "global" in node.op:
            vis[node.name] = False
        elif "FakeQuant" in node.op:
            vis[node.name] = False
        elif node.name in assume_variable_nodes:
            vis[node.name] = False
        else:
            ret = True
            vis[node.name] = False
            for innode in node.inputs:
                if isinstance(innode, str):
                    inname = innode
                else:
                    inname = innode.name
                if inname not in vis:
                    visit(innode)
                if not vis[inname]:
                    ret = False
                    break
            vis[node.name] = ret

    for k, v in gd.items():
        if k in vis:
            continue
        visit(k)

    ret = []
    for k, v in vis.items():
        if v:
            ret.append(k)
    return ret

    Given a graph, extract all nodes that only depends on const nodes.

    # TODO: extract nodes that depends on the "const part" of placeholders.
    
coremltools/converters/mil/frontend/tensorflow/basic_graph_ops.py