def _fix_found_cond(g, merge, switches):
        """
        Convert a Merge's Switch nodes to Identity ops and the Merge to iff.
        """
        if g[switches[0]].op == "Switch":
            condition_input = g[switches[0]].inputs[1]
        else:
            condition_input = g[switches[0]].attr["was_switch"]

        # convert the merge to a select
        # TensorFlow seems to ensure the condition that the first
        # merge input is the True branch and the second merge input
        # is the false branch.

        # we convert switches to identity, detaching to switch condition
        for s in switches:
            if g[s].op == "Switch":
                g[s].op = "Identity"
                g[s].attr["was_switch"] = g[s].inputs[1]
                # detach input 1: the switch condition
                if g[s].inputs[0] == g[s].inputs[1]:
                    g[s].inputs.pop()
                    g[g[s].inputs[0]].outputs.pop()
                else:
                    disconnect_edge(g, g[s].inputs[1], s)

        # build the final select
        g[merge].op = "iff"
        if not _HAS_TF_2:
            # swap true branch with false branch to get the right semantics for IFF
            g[merge].inputs[0], g[merge].inputs[1] = (
                g[merge].inputs[1],
                g[merge].inputs[0],
            )

        g[merge].inputs = [condition_input] + g[merge].inputs
        g[condition_input].outputs.append(merge)

        Convert a Merge's Switch nodes to Identity ops and the Merge to iff.
        
coremltools/converters/mil/frontend/tensorflow/tf_graph_pass/cond_to_where.py